Files
mkdocs/docs/Linux/links.md
2025-03-25 15:52:48 +01:00

2.0 KiB
Raw Blame History

Links

  • 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
~/.local/bin                                                                                                                                        
$ ln -s ~/Documents/Scripts/pihole/sync_pihole_lan.sh sync_pihole
~/.local/bin                                                                                                                                        
$ ln -s ~/Documents/Scripts/bashbirds/bashbirds.sh bashbird
  • 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
~ 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.

Origine d'un lien

/opt/homebrew/share/zsh/site-functions stable                                                 

 readlink -f _yq
/opt/homebrew/Cellar/yq/4.40.5/share/zsh/site-functions/_yq