linux中 ls -l 命令后的一个数字的解释

来源:百度知道 编辑:UC知道 时间:2024/07/03 02:37:35
当我敲入ls -l之后, 会出现-rwxrwxrwx n(是一个数字)后面是用户名..., 前面的是权限,我知道,就是不知道后面跟的这个数字是什么意思,请教一下,谢谢

楼上说错了..

按照ls的man文档说明 紧跟权限后的数字用于描述链接数
详细的解释就是 权限后面跟着的数字就是表示这个文件和目录有多少个硬链接

# ls -il
606250 -rw-r--r-- 1 root root 8791 Sep 20 16:43 commands
606223 drwxr-xr-x 36 root root 4096 Jun 21 12:59 test
606274 lrwxrwxrwx 1 root root 8 Sep 30 17:00 test1 -> testfile
606292 lrwxrwxrwx 1 root root 8 Sep 30 17:00 test2 -> testfile
606262 -rw-r--r-- 4 root root 0 Sep 30 16:59 test3
606262 -rw-r--r-- 4 root root 0 Sep 30 16:59 test4
606262 -rw-r--r-- 4 root root 0 Sep 30 16:59 test5
606299 lrwxrwxrwx 1 root root 8 Sep 30 17:06 test6 -> testfile
606262 -rw-r--r-- 4 root root 0 Sep 30 16:59 testfile

上例中,以ls -il输出 第一列是文件的inode

文件testfile一共有4个硬链接 这是包含本身的,也就是说 除了testfile自身 还有三个硬链接链接到文件的inode 所以此列显示为4 这点可以从inode的比较看出来 ,test3 test4 test5 是testfile的硬链接

目录test 其目录一共含56个硬链接, 所以显示出56

一个文件最少有一个硬链接。
一个目录(比如是/home/dir)则至少有2个硬链接,一个是目录本身(/home/dir)的入口,这个/home/dir目