Session and utilities

The file command

Guesses a file's real type by looking at its content, not its extension. Very useful when you do not know what it is.

Syntax

file archivo...

Most useful options

-iShows the MIME type
-bWithout the file name in front

Copy-ready examples

$ printf 'hola\n' > f.txt && file f.txtFile type

You can try them in the browser terminal: it does not touch your computer.

Typical mistakes

  • The extension does not matter: a .txt that is really an image is detected as an image.

Related commands

FAQ

How does it know the type?

It reads the first bytes and compares them with known signatures (magic numbers).

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course