How to Use the file Command in Linux

Category: Advanced – Command Line • Est. reading time: 1 minute

The file command tells you what a file actually is by inspecting its contents, not just its extension. It is often used in scripts before acting on a file.

Check a file

file report.txt        # => report.txt: ASCII text

Show the MIME type

file -i backup.sql     # => backup.sql: text/plain; charset=us-ascii

Look inside a compressed file

file -z archive.tar.gz

Running your own dedicated or self-managed server? We are glad to help. Reach us at support@allydrez.com or 1-321-209-2004.