14-11-2023
This commit is contained in:
78
docs/Linux/links.md
Normal file
78
docs/Linux/links.md
Normal file
@@ -0,0 +1,78 @@
|
||||
# Links
|
||||
|
||||
|
||||
|
||||
### soft link (symbolic link):
|
||||
|
||||
- ln -s
|
||||
- contient le chemin du fichier original
|
||||
- link des répertoires
|
||||
|
||||
```bash
|
||||
~ mkdir link
|
||||
|
||||
~ touch link/hello.txt
|
||||
|
||||
~ ln -s link/hello.txt
|
||||
|
||||
~ ls
|
||||
hello.txt link
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Créer un lien symbolic
|
||||
|
||||
```bash
|
||||
~ 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
|
||||
|
||||
```bash
|
||||
~ touch file_1 file_2
|
||||
|
||||
~ ls -i
|
||||
43767553 file_1 43767554 file_2
|
||||
```
|
||||
|
||||
```bash
|
||||
~ 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
|
||||
|
||||
```bash
|
||||
~ ln file_1 hard_ln
|
||||
```
|
||||
|
||||
```bash
|
||||
~ 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.
|
||||
Reference in New Issue
Block a user