Quickly identify what a file actually contains to make the right next step on the command line. 14.03.2026 | reading time: 2 min On a busy shell he wants to know whether a mystery file is text, an image, or an executable; the `file` command answers that question by examining file contents rather than relying on names or extensions. Quick demo Try this on a Linux system to see `file` in action: ```sh echo "Hello world" > hello.txt file hello.txt file /bin/ls printf '\xFF\xD8\xFF' > image.jpg file image.jpg ``` Typical output might look like: ```sh hello.txt: ASCII text /bin/ls: ELF 64-bit LSB shared object, x86-64, dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux image.jpg: JPEG image data, JFIF standard 1.01 ``` Options you will use Always start simple and add switches as needed: use `-b` for brief output, `-i` or `--mime` to get MIME type and encoding, `-s` to read special files such as block devices, `-L` to follow symlinks, `-k` to keep trying additional matches, and `-m` to point to a custom magic database; combine `file --mime-type` with `find` and `xargs` to classify thousands of files in scripts. When file is not enough For deeper inspection drop into specialized tools: `strings` extracts printable text from binaries, `hexdump` or `xxd` shows raw bytes, `readelf` or `objdump` inspect ELF internals, and `exiftool` reads metadata from images and media; use these when `file` tells you the type but you need structure or metadata details. Wrap-up and next steps The `file` command is small, fast, and often the right first diagnostic on unknown files; learn to combine it with `find`, `xargs`, and the inspection tools above to build reliable file-classification or triage scripts, and consider advancing your Linux skills with formal study such as CompTIA Linux+ or LPIC-1 where commands like `file` are part of real-world tasks — check bitsandbytes.academy for intensive exam preparation. Join Bits & Bytes Academy First class LINUX exam preparation. utilities filesystem scripting