1er commit
De la docs au format Mkdocs
This commit is contained in:
135
docs/Linux/permissions.md
Normal file
135
docs/Linux/permissions.md
Normal file
@@ -0,0 +1,135 @@
|
||||
# Permissions
|
||||
|
||||
#### Quelques commandes:
|
||||
|
||||
- su - temporarily become the superuser
|
||||
- sudo - temporarily become the superuser
|
||||
- chmod - modify file access rights
|
||||
- chown - change file ownership
|
||||
- chgrp - change a file's group ownership
|
||||
|
||||
|
||||
|
||||
```
|
||||
-rwxrwxrwx
|
||||
|
||||
[- (fichier) ou d (dossier)] [rwx (possesseur) - rwx (groupe) - rwx (autres)]
|
||||
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### chmod: change les permissions pour un fichier ou un dossier
|
||||
|
||||
```
|
||||
rwx rwx rwx = 111 111 111
|
||||
rw- rw- rw- = 110 110 110
|
||||
rwx —–- -–— = 111 000 000
|
||||
```
|
||||
|
||||
et
|
||||
|
||||
```
|
||||
rwx = 111 in binary = 7
|
||||
rw- = 110 in binary = 6
|
||||
r-x = 101 in binary = 5
|
||||
r–- = 100 in binary = 4
|
||||
```
|
||||
|
||||
**Les réglages les plus courants:**
|
||||
|
||||
*-applications:*
|
||||
|
||||
```
|
||||
777 (rwxrwxrwx)
|
||||
755 (rwxr-xr-x)
|
||||
700 (rwx——)
|
||||
```
|
||||
|
||||
*-fichiers:*
|
||||
|
||||
```
|
||||
666 (rw-rw-rw-)
|
||||
644 (rw-r–r–)
|
||||
600 (rw——-)
|
||||
```
|
||||
|
||||
**Permissions pour les dossiers:**
|
||||
|
||||
- r: permet de lister le contenu d'un répertoire si l'attribut x est mis
|
||||
|
||||
- w: les fichiers à l'intérieur du répertoire peuvent être crées, effacés ou renommer si l'attribut x est mis
|
||||
- x: permet d'entrer dans le répertoire (cd dir)
|
||||
|
||||
```
|
||||
777 (rwxrwxrwx)
|
||||
755 (rwxr-xr-x)
|
||||
700 (rwx——)
|
||||
```
|
||||
|
||||
|
||||
|
||||
```bash
|
||||
bruno@macbook-pro:~$ ls -la
|
||||
-rw-r--r--@ 1 bruno staff 848 6 aoû 09:20 backup-syno.tar.gz
|
||||
bruno@macbook-pro:~/test-dossier-2$ chmod 777 backup-syno.tar.gz
|
||||
bruno@macbook-pro:~$ ls -la
|
||||
-rwxrwxrwx@ 1 bruno staff 848 6 aoû 09:20 backup-syno.tar.gz
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### chown: change le possesseur d'un fichier ou dossier (superuser)
|
||||
|
||||
```bash
|
||||
bruno@macbook-pro:~$ ls -la
|
||||
-rwxrwxrwx@ 1 bruno staff 848 6 aoû 09:20 backup-syno.tar.gz
|
||||
bruno@macbook-pro:~$ sudo chown root backup-syno.tar.gz
|
||||
Password:
|
||||
bruno@macbook-pro:~$ ls -la
|
||||
-rwxrwxrwx@ 1 root staff 848 6 aoû 09:20 backup-syno.tar.gz
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### chgrp: change le groupe d'un fichier ou dossier (superuser)
|
||||
|
||||
```bash
|
||||
bruno@macbook-pro:~$ ls -la
|
||||
-rwxrwxrwx@ 1 root staff 848 6 aoû 09:20 backup-syno.tar.gz
|
||||
bruno@macbook-pro:~$ sudo chgrp admin backup-syno.tar.gz
|
||||
bruno@macbook-pro:~$ ls -la
|
||||
-rwxrwxrwx@ 1 root admin 848 6 aoû 09:20 backup-syno.tar.gz
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### setuid:
|
||||
|
||||
```
|
||||
# chown root:root monshell.sh
|
||||
# chmod 4755 monshell.sh
|
||||
# exit
|
||||
$ ./monshell.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Voir les autorisations au format octal:
|
||||
|
||||
**-Linux:**
|
||||
|
||||
```bash
|
||||
stat -c '%n %a' *
|
||||
```
|
||||
|
||||
**-OSX**:
|
||||
|
||||
```bash
|
||||
bruno@Parallels-VM ~ $ stat -c '%n %a' *
|
||||
apt-off.sh 755
|
||||
Bureau 755
|
||||
Documents 755
|
||||
Images 755
|
||||
```
|
||||
Reference in New Issue
Block a user