How To Use File Comand.
The file command displays the type of a file.
Linux File Command Syntax
The syntax for the Linux file command is as follows:
It can take one or more file names as its arguments.
How to Use the file Command to Find the File Type
The file command classifies files based on a series of tests and determines the file type based on the first successful test.
In its simplest form when used without any option, the file command will display the file name along with the file type:
To show just the file type use the -b (–brief) option:
As you can see from the output above the /etc/group file is a text file.
How to Find the File Type of Multiple Files
You can pass more than one files to the file command:
The command will print the type of each file on a separate file:
It also accepts wildcard characters. For example, to find the type of each .jpg files in the current directory you would run:
How to View the Mime Type of a File
Use the -i (–mime) option to determine the mime type of a file:
By now you should have a good understanding of how to use the Linux file command.