Linux file command

The file command is used to check a file’s type and contents in Linux environment. It is most commonly used in bash scripts and in this article we will show you the basic usage of the Linux file command.

Display info about a file

This will display a text with the file’s description, for example, “HTML document, UTF-8 Unicode text, with very long lines” or “Zip archive data, at least v2.0 to extract”

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

Viewing mime type

file -i database.sql # => database.sq: text/html; charset=utf-8

You can also try to look into an archive

file -z myArchive.tar.gz

Master your Linux knowledge with our List of Top Linux Commands for Beginners and Experts. Test your knowledge with different Linux commands on a Linux Dedicated server, Private VPS or an SSH Shared Hosting account now! Get Shared hosting account with SSH with 40% discount OFF the regular price!

Vladimir P.

Share
Published by
Vladimir P.