Easy Tutorial
❮ Linux Comm Smbd Linux Comm Cu ❯

Linux file Command

Linux Command Manual

The Linux file command is used to determine the type of a file.

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

Syntax

file [-bcLvz][-f <name file>][-m <magic number file>...][files or directories...]

Parameters:

Examples

Display file type:

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

[root@localhost ~]# file -b install.log      <== Do not display the filename
UTF-8 Unicode text

[root@localhost ~]# file -i install.log      <== Display MIME type.
install.log: text/plain; charset=utf-8

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

Display file type of symbolic links:

[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 Manual

❮ Linux Comm Smbd Linux Comm Cu ❯