Links rígidos para '/'?

0

Existem 24 hardlinks para o meu / no Ubuntu:

$ ls -ld /
drwxr-xr-x 24 root root 4096 May  6 13:39 /

Eu quero saber o que eles são.

É correto que /. e /.. sejam dois links para / ?

$ 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

Existem 27 arquivos em / e / tem 4 links simbólicos e 23 subdiretórios cada um contendo um link para / :

$ 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

Em seguida, deve haver 23 + 2 = 25 hard links para / . Mas por que existem 24?

Obrigado.

    
por Tim 07.05.2015 / 04:21

1 resposta

3

Existem 28 arquivos, incluindo diretórios.

ls / | wc -l inclui a linha "total", mas não os diretórios . e .. , portanto seus 27 se tornam 28.

Subtraia initrd.img , initrd.img.old , vmlinuz e vmlinuz.old , pois eles não são links de diretório (são arquivos regulares ou links simbólicos), fazendo 24.

    
por 07.05.2015 / 04:46

Tags