How to find out original extension of a file in a terminal or online
pls help me

Dani AI

Generated

— the file extension itself is just a name; Linux does not keep a separate record of the "original" extension. and pointed toward inspecting the file and using an automated detector. Those are the right directions. The most reliable results come from combining a few complementary checks rather than relying on a single tool.

Start by working on a copy. Use format-specific inspectors: metadata readers for photos, media analyzers for audio/video, PDF/Office utilities for documents, and archive listers for compressed containers. Many modern document formats are actually archives (ZIP-based), so listing their contents will often reveal internal filenames and the real types. For images and media, a metadata dump will typically name the container and codec; for office files, look for manifest or content-type entries.

If you get a MIME type from a detector, map it to common extensions via the system MIME database or a language library. Be aware that one MIME type can map to several extensions (for example, text/ or image/), so pick the extension that matches the applications you intend to use. For ambiguous or embedded blobs (firmware, concatenated payloads), try tools that scan inside a binary for known signatures or list internal files — those often expose the true payload type.

Practical cautions: encrypted or corrupted files may not be identifiable. Some formats share header bytes and can be misidentified. Never rename the only copy until you confirm it opens correctly. If automated methods fail, check the transfer source (original email headers, HTTP logs, version-control history) — those commonly record the original filename and MIME type.

Recommended Answers

All 2 Replies

You will probably need to open the file in a hex editor and look at the first 2 to 3 bytes to figure out the file type or maybe you can just open it in a text editor. After that, you can google those characters to find out the file type and extension.

Try the "file" command. It'll look up the magic number and try to tell you what program created the file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.