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 // 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 |
Explore our comprehensive directory of recommended free and open source software. Our carefully curated collection spans every major software category.This directory is part of our ongoing series of informative articles for Linux enthusiasts. It features hundreds of detailed reviews, along with open source alternatives to proprietary solutions from major corporations such as Google, Microsoft, Apple, Adobe, IBM, Cisco, Oracle, and Autodesk. You’ll also find interesting projects to try, hardware coverage, free programming books and tutorials, and much more. Know a useful open source Linux program that we haven’t covered yet? Let us know by completing this form. |

