file determines the type of data contained in a file by examining its contents rather than relying on filename extensions. It is commonly used to identify unknown files, verify file formats, and diagnose issues with corrupted or misnamed files.
The command analyses files using several tests and a database of “magic numbers” that correspond to known file signatures and formats.
This is free and open source software.
Key Features
- Determines the type of a file by examining its contents rather than relying on filename extensions.
- Uses a database of magic numbers to recognise hundreds of file formats.
- Identifies file categories such as text files, executables, images, archives, and multimedia files.
- Performs multiple checks including filesystem tests and pattern matching.
- Can output MIME types suitable for scripts and automation.
- Works with regular files, directories, symbolic links, and special files.

| Alternatives to file | |
|---|---|
| fil | Unix file command written in Go |
| mimetype | Determines the MIME type of files |
| xdg-mime | Part of xdg-utils |
| TrID | Identify file types from their binary signatures |
| binwalk | Search a given binary image for embedded files |
All the CLI tools in this series.
| Alternatives to CLI tools |
|---|
| age // awk // bc // cal // cat // cd // chmod // cksum // cloc // cmp // compress // cp // cron // curl // cut // date // dd // df // diff // dig // du // fdisk // file // find // free // ftp // grep // gzip // hexdump // history // jq // kill // less // locate // ls // lsof // make // man // more // mv / ping // ps // psql // rename // rm // sed // split // ssh // stow // strings // sudo // sysctl // tail // talk // tar // telnet // time // top // touch // traceroute // tree // uname // uniq // uptime // vi // watch // Wget // who // whois // xargs |
LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more. Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion. Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README. |


Please read our Comment Policy before commenting.