Use the file command of linux to identify file types
Editor to share with you the use of linux's file command to identify file types, I hope you have learned a lot after reading this article, let's discuss it together!
The file command is used to identify file types and can also be used to identify the encoding format of some files. It gets the file type by looking at the header information of the file, rather than determining the file type by extension, as Windows does.
Syntax format: file [parameters] [file]
Common parameters:
When the identification results are listed, the file name (brief mode) is not displayed.-c shows the instruction execution process in detail to facilitate troubleshooting or analyze the execution of the program.
Often used with-m to debug the magic number file before installing it-f specified name files, which have one or more file names, let file identify the files in order, in the format of one file name per column-L directly displays the file category pointed to by the symbolic link-m specifies the magical digital file-v display version information-z attempts to interpret the contents of the compressed file-I display the MIME category
Reference example:
Displays the file type:
[root@linuxcool ~] # file install.log
Install.log: UTF-8 Unicode text
Displays the file type, not the file name:
[root@linuxcool] # file-b install.log
UTF-8 Unicode text
Displays the file type, the MIME category, and does not show the file name:
[root@linuxcool] # file-b-I install.log
Text/plain; charset=utf-8
Displays the file type of the symbolic link:
[root@linuxcool ~] # ls-l / var/mail
Lrwxrwxrwx 1 root root 10 08-13 00:11 / var/mail-> spool/mail
[root@linuxcool ~] # file / var/mail
/ var/mail: symbolic link to `spool/mail'
Displays the file category that the symbolic link points to:
[root@linuxcool] # file-L / var/mail
/ var/mail: directory has finished reading this article. I believe you have some understanding of using linux's file command to identify file types. If you want to know more about it, welcome to follow the industry information channel. Thank you for reading!