Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Linux file Command

Linux file Command

Linux Command Reference Linux Command Reference

The Linux file command is used to identify file types.

With the file command, we can identify the type of a file.

Syntax

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

Parameters:

Example

Display 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 the file type of a symbolic link



[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 Reference Linux Command Reference