3.2.8 查看文件类型:file
之前已经讲到,使用ls-l命令可以通过查看第一个字符判断文件类型。字母d代表目录、字母l代表连接文件,字母b代表块文件,字母c代表字符文件,字母s代表socket文件,字符-代表普通文件,字母p代表管道文件,而file命令则可以直接告诉我们文件类型,还能给出更多的文件信息,如下所示:
- #/root
是一个目录
[john@localhost ~]$ file /root
/root: directory
#/tmp
是一个拥有sticky
属性的目录
[john@localhost ~]$ file /tmp
/tmp: sticky directory
#
使用ls
–l
命令查看,显示这是一个普通文件
[john@localhost ~]$ ls -l etcpasswd
-rw-r--r-- 1 root root 1453 Jan 4 18:12 etcpasswd
#
使用file
命令查看,显示这是一个ASCII
编码的文本文件
[john@localhost ~]$ file etcpasswd
etcpasswd: ASCII text
#
使用ls
–l
命令查看,显示这是一个普通文件,看不出与etcpasswd
的差别
[john@localhost ~]$ ls -l usrbin/passwd
-rwsr-xr-x 1 root root 22984 Jan 7 2007 usrbin/passwd
#
使用file
命令查看,显示这是一个32
位的可执行性二进制文件
[john@localhost ~]$ file usrbin/passwd
usrbin/passwd: setuid ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV),
for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, stripped