Links指向
指向/
的硬連結?
在 Ubuntu 上有 24 個指向 my的硬連結
/
:$ ls -ld / drwxr-xr-x 24 root root 4096 May 6 13:39 /
我想知道它們是什麼。
這是正確的,
/.
並且/..
是兩個硬連結/
嗎?$ ls -a / . bin cdrom etc initrd.img lib lost+found mnt proc run share sys usr vmlinuz .. boot dev home initrd.img.old lib64 media opt root sbin srv tmp var vmlinuz.old $ ls /.. bin cdrom etc initrd.img lib lost+found mnt proc run share sys usr vmlinuz boot dev home initrd.img.old lib64 media opt root sbin srv tmp var vmlinuz.old
下有 27 個文件
/
,並且/
有 4 個符號連結和 23 個子目錄,每個子目錄都包含指向 的硬連結/
:$ ls / -l |wc -l 27 $ ls -l / total 108 drwxr-xr-x 2 root root 4096 Apr 16 08:10 bin drwxr-xr-x 3 root root 4096 May 5 10:46 boot drwxrwxr-x 2 root root 4096 Mar 8 22:10 cdrom drwxr-xr-x 17 root root 4640 May 6 19:56 dev drwxr-xr-x 148 root root 12288 May 6 18:31 etc drwxr-xr-x 4 root root 4096 Mar 8 22:12 home lrwxrwxrwx 1 root root 33 May 5 10:44 initrd.img -> boot/initrd.img-3.16.0-37-generic lrwxrwxrwx 1 root root 33 Apr 30 12:19 initrd.img.old -> boot/initrd.img-3.16.0-36-generic drwxr-xr-x 24 root root 4096 Mar 9 11:48 lib drwxr-xr-x 2 root root 4096 Mar 8 22:23 lib64 drwx------ 2 root root 16384 Mar 8 22:07 lost+found drwxr-xr-x 3 root root 4096 Mar 8 22:53 media drwxr-xr-x 2 root root 4096 Apr 10 2014 mnt drwxr-xr-x 9 root root 4096 Apr 15 23:43 opt dr-xr-xr-x 252 root root 0 May 4 07:30 proc drwx------ 8 root root 4096 Mar 15 22:46 root drwxr-xr-x 27 root root 940 May 6 13:11 run drwxr-xr-x 2 root root 12288 Apr 24 03:21 sbin drwxr-xr-x 3 root root 4096 Apr 22 19:24 share drwxr-xr-x 2 root root 4096 Feb 18 14:33 srv dr-xr-xr-x 13 root root 0 May 6 22:12 sys drwxrwxrwt 15 root root 12288 May 6 22:17 tmp drwxr-xr-x 10 root root 4096 Apr 22 19:19 usr drwxr-xr-x 13 root root 4096 Feb 18 14:41 var lrwxrwxrwx 1 root root 30 May 5 10:44 vmlinuz -> boot/vmlinuz-3.16.0-37-generic lrwxrwxrwx 1 root root 30 Apr 30 12:19 vmlinuz.old -> boot/vmlinuz-3.16.0-36-generic
那麼應該有 23+2=25 個硬連結到
/
. 但是為什麼有24個?謝謝。
有 28 個文件,包括目錄。
ls / | wc -l
包括“總”行,但不包括.
and..
目錄,因此您的 27 變為 28。減去
initrd.img
,initrd.img.old
,vmlinuz
和vmlinuz.old
, 因為它們不是目錄連結(它們是正常文件或符號連結),所以 24。