While file extensions in Linux are optional and often misleading, the file
command helps decode what a file truly is. This powerful utility analyzes the actual content, not just the name, and offers a reliable description, vital for system admins, developers, and anyone working with unknown or mixed file types.
file [options] filename
Replace filename
with the file to analyze.
file music_track
Returns “MP3 audio file” (or “ASCII text” if it’s actually just text, regardless of its .mp3
extension).
file *.jpg
Instantly reveals which among your *.jpg
files are actual images or just misnamed files.
file ~/Documents/backup*
Shows what types of backups you actually have (compressed, database dumps, raw text, etc.).
file install.sh
Output might show “Bourne-Again shell script,” or “ELF 64-bit LSB executable” for compiled binaries.
Option | Function |
---|---|
-b | Hide file name in output |
-i | Show MIME type instead of English descriptor |
-L | Follow symbolic links |
-z | Look inside compressed files |
Read More: History of Linux
The touch command is one of the quickest ways to create new empty files or update timestamps…
Handling large numbers of files is routine for Linux users, and that’s where the find command shines.…
Managing files and directories is foundational for Linux workflows, and the mv (“move”) command makes it easy…
Creating directories is one of the earliest skills you'll use on a Linux system. The mkdir (make…
Lyric videos have become one of the most popular tools for artists to share music…
The cp command, short for "copy," is the main Linux utility for duplicating files and directories. Whether…