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