File command on Linux (check file type)
The file command in Linux is used to determine the type of file entered as a parameter based on the Magic Number (first two bytes).
Unlike Windows, file extensions mean nothing in Linux. The file command performs three types of checks to determine the file type:
- File system testing;
- Magic Number testing;
- Language testing
The first file system test is done to determine whether the file is an ordinary file, a directory, a link, a device, a connection socket, etc. In Linux, absolutely everything is a file. The type of file in the file system determines whether it is a regular file or another special type.
The third test, once it has been determined that the file is a program, script, or source code, indicates the program’s language.
Examples:
Learn much more about Linux in our online course. You can register here. If you already have an account, or want to create one, just log in or create your user here.
Did you like it?
Share