Links¶
soft link (symbolic link):¶
- ln -s
- contient le chemin du fichier original
- link des répertoires
~ mkdir link
~ touch link/hello.txt
~ ln -s link/hello.txt
~ ls
hello.txt link
Créer un lien symbolic¶
~ ln -s link/hello.txt hello_you.txt
~❯ ls
hello.txt link hello_you.txt
hard link:¶
- ln
- contient le contenu du fichier original (le hardlink et le fichier original partagent le même inode)
- ne link pas des répertoires
Inode number¶
~ touch file_1 file_2
~ ls -i
43767553 file_1 43767554 file_2
~ ls -l
-rw-r--r-- 1 bruno staff 0 mai 6 18:29 file_1
-rw-r--r-- 1 bruno staff 0 mai 6 18:29 file_2
Créer un hard-link¶
~ ln file_1 hard_ln
~ ls -li
43767553 -rw-r--r-- 2 bruno staff 0 mai 6 18:29 file_1
43767554 -rw-r--r-- 1 bruno staff 0 mai 6 18:29 file_2
43767553 -rw-r--r-- 2 bruno staff 0 mai 6 18:29 hard_ln
43768356 lrwxr-xr-x 1 bruno staff 14 mai 6 18:46 hello.txt -> link/hello.txt
43768828 lrwxr-xr-x 1 bruno staff 14 mai 6 18:50 hello_you.txt -> link/hello.txt
43768326 drwxr-xr-x 3 bruno staff 96 mai 6 18:46 link
file_1 et hard_ln ont le même inode.
Si on supprime file_1
, hard_ln
conserve le même contenu.
Dernière mise à jour:
November 9, 2023