File Operations

file

Determine the type of a file by examining its content and magic bytes.

Synopsis

syntax
file [OPTION]... FILE...

Examples

Identify a file's type
file document.pdf
Show MIME type of a file
file -i image.png
Identify all files in current directory
file *
Show type without filename prefix
file -b archive.tar.gz

Common options

FlagDescription
-iOutput MIME type string
-bBrief mode — omit filename
-zLook inside compressed files
-LFollow symlinks

About file

The `file` command determine the type of a file by examining its content and magic bytes. File operation commands are essential for navigating and managing the Linux filesystem.

They form the backbone of everyday system administration and development workflows. Mastering these commands enables you to efficiently create, move, copy, and organize files and directories from the terminal, which is often faster and more scriptable than graphical alternatives.

The command accepts 4 commonly used flags shown above, though the full set of options is available in the man page (`man file`). The 4 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.

Related commands

More File Operations Commands

Other commands in the File Operations category

Related tools