Sometimes while working with Linux systems, you will see the type of file that you may have never known before.
Linux supports you with a command you can determine the type of file. This command is quite simple but it can be useful for you in some cases.
Show type of file with “file” command
As you can see, the name of the command says its meaning, the file
command is used to determine the type of the file.
The simplest is to call the file
command and the name of the file you need to determine behind that.
file name-of-the-file
The example below, I will determine the type of file install.log
– this is a common file when you install CentOS virtual servers. The results showed that this is an ASCII text file.
So what if you want to check what kind of file is in a compressed file? In this case, we will use the -z
parameter in the file command.
- -z: try to look inside compressed files.
In the example below, I have compressed the install.log
file into a compressed file named install.zip
. When we use the file
command to test the compressed file, it returns the result as a zip file. But when we use the parameter -z
, it will return results about the type of files inside compressed files.
For the other parameters of the file command, type:
file --help
Conclusion
File commands can be very simple (I’m trying to talk about the simplest thing) but it can be very helpful for you in the future. For example, you download a compressed file for installation, but you do not know what exactly is inside the compressed file. When you extract the file, can you spread the virus? I suppose so, then the file
command will help you somewhat in this case.
(This is an article from my old blog that has been inactive for a long time, I don’t want to throw it away so I will keep it and hope it helps someone).