Linux文件类型
Linux 类型
(参考于千锋教育)
==================================================
方法一:
ls -l 文件名 //查看第一个字符
- 普通文件 [文本文件,二进制文件,压缩文件,........]
d 目录文件(direcyory)
b 设备文件(块设备) (block) { /dev/sda,/dev/sda1,U盘,.......}
c 设备文件(字符设备) (character) {打印机,终端/dev/tty1,dev/zero}
s 套接字文件(socket)
p 管道文件(fifo:for in for out《先进先出》)
l 链接文件(link)
示例:
[root@sambo ~]# ll -d /etc/hosts /bin/ls /dev/sda /dev/tty1 /etc/grub2.cfg /home /run/dmeventd-client
-rwxr-xr-x. 1 root root 117656 11月 6 2016 /bin/ls
brw-rw---- 1 root disk 8, 0 6月 9 15:15 /dev/sda
crw--w---- 1 root tty 4, 1 6月 9 15:15 /dev/tty1
lrwxrwxrwx. 1 root root 22 8月 2 2017 /etc/grub2.cfg -> ../boot/grub2/grub.cfg
-rw-r--r-- 1 root root 65 3月 12 15:41 /etc/hosts
drwxr-xr-x. 19 root root 240 5月 31 14:53 /home
prw------- 1 root root 0 6月 9 15:15 /run/dmeventd-client
方法二:
file 文件名
示例:
[root@sambo ~]# file /etc/hosts
/etc/hosts: ASCII text //普通文本文件
[root@sambo ~]# 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]=3d705971a4c4544545cb78fd890d27bf792af6d4, stripped
[root@sambo ~]# file /dev/sda
/dev/sda: block special //块设备文件
[root@sambo ~]# file /dev/tty1
/dev/tty1: character special //字符设备
[root@sambo ~]# file /etc/grub2.cfg
/etc/grub2.cfg: symbolic link to `../boot/grub2/grub.cfg' //l链接文件
[root@sambo ~]# file /home
/home: directory //目录文件
[root@sambo ~]# file /run/dmeventd-client
/run/dmeventd-client: fifo (named pipe) //管道文件