English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Linux file command

Linux Command大全

The Linux file command is used to identify file types.

Through the file command, we can identify the type of the file.

Syntax

file [-bcLvz][-f <Name File>][-m <Magic Number File>...][File or Directory...]

Parameters:

  • -b  When listing identification results, do not display file names.
  • -c  Detailedly display the execution process of the command, convenient for debugging or analyzing the execution situation of the program.
  • -f<Name File>  Specify the name file, its content contains one or more file names, so that file can sequentially identify these files, with the format of one file name per column.
  • -L  Directly display the category of the file pointed to by the symbolic link.
  • -m<magic number file>  Specify a magic number file.
  • -v  Display version information.
  • -z  Attempt to interpret the content of compressed files.
  • [File or Directory...] To determine the type of a file list, separate multiple files with spaces, and you can use shell wildcard characters to match multiple files.

Online Examples

Display File Type:

[root@localhost ~]# file install.log
install.log: UTF-8 Unicode text
[root@localhost ~]# file -b install.log      <== Do not display file name
UTF-8 Unicode text
[root@localhost ~]# file -i install.log      <== Display MIME category.
install.log: text/plain; charset=utf-8
[root@localhost ~]# file -b -i install.log
text/plain; charset=utf-8

Display Symbolic Link File Type

[root@localhost ~]# ls -l /var/mail
lrwxrwxrwx 1 root root 10 08-13 00:11 /var/mail -> spool/mail
[root@localhost ~]# file /var/mail
/var/mail: symbolic link to `spool/mail'
[root@localhost ~]# file -L /var/mail
/var/mail: directory
[root@localhost ~]# file /var/spool/mail
/var/spool/mail: directory
[root@localhost ~]# file -L /var/spool/mail
/var/spool/mail: directory

Linux Command大全