Latest web development tutorials

Linux file command

Linux command Daquan Linux command Daquan

Linux file command is used to identify the file type.

By file command, we were able to identify the type of the file.

grammar

file [-beLvz][-f <名称文件>][-m <魔法数字文件>...][文件或目录...]

Parameters:

  • When -b lists the recognition result, the file name is not displayed.
  • -c detailed display process execution instruction, to facilitate troubleshooting or analyzing the case of program execution.
  • -f <file name> Specifies the name of the file, the contents of one or more file names do sense, so that file sequentially identify these files, a file format for each column name.
  • -L Displayed directly Collections symbolic link points to a file.
  • -m <file magic number> Specifies magic digital files.
  • -v Displays version information.
  • -z try to interpret the contents of compressed files.
  • [File or directory ...] to determine the type of file list, separated with spaces between multiple files, you can use shell wildcards to match multiple files.

Examples

Display the file types:

[root@localhost ~]# file install.log
install.log: UTF-8 Unicode text

[root@localhost ~]# file -b install.log      <== 不显示文件名称
UTF-8 Unicode text

[root@localhost ~]# file -i install.log      <== 显示MIME类别。
install.log: text/plain; charset=utf-8

[root@localhost ~]# file -b -i install.log
text/plain; charset=utf-8

Display symbolic link file types

[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 Daquan Linux command Daquan