描述:查看某个文件的基本信息
用法:file [option] 文件名
常用参数:
-f:查看文件中的文件名的文件类型
-z:尝试去解读压缩文件的内容
-L:查看软连接对应的文件类型
示例:1.使用file命令查看/bin/ls的文件信息
[root@share19 ~]# file /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=0xec333a104e045327c5e3d0ca6dda16c610a210f3, stripped
2.尝试去解读压缩文件的内容
[root@DB-Server ~]# file -z Temp.txt.gz
Temp.txt.gz: UTF-8 Unicode text, with very long lines, with CRLF line terminators (gzip compressed data, was "Temp.txt", from Unix, last modified: Tue Jun 24 00:34:15 2014)
3.查看软连接对应的文件类型
[root@DB-Server ~]# ln -s Temp.txt.gz sfile
[root@DB-Server ~]# file sfile
sfile: symbolic link to `Temp.txt.gz'
[root@DB-Server ~]# file -L sfile
sfile: gzip compressed data, was "Temp.txt", from Unix, last modified: Tue Jun 24 00:34:15 2014