Last active
February 10, 2017 14:06
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Permissions | |
Change permissions for user, groups, and others on files and directories. | |
## Command | |
chmod | |
## Syntax | |
chmod -destination+-permissions /path/to/dir/or/file | |
### Recursive argument | |
none | |
### Permissions add | |
chmod +rwx | |
#### r stands for "read", w for "write", and x for "execute" | |
### Permissions remove | |
chmod -rwx | |
### Permissions for user/group/others/all | |
chmod -u+rwx | |
chmod -g+rwx | |
chmod -o+rwx | |
chmod -a+rwx | |
### Multiple permissions at once | |
chmod -u+r,g-w,o-rwx | |
### Copy permissions from a group to another | |
chmod dest=source | |
#### Example : chmod -R g=u /home/userdir/subdir | |
### Set all permissions at once | |
chmod 777 == chmod -a+rwx | |
chmod 000 == chmod -a-rwx | |
#### First number is for user, second is for group, third for others | |
#### Values | |
0 no permissions | |
1 x | |
2 w | |
3 wx | |
4 r | |
5 rx | |
6 rw | |
7 rwx | |
#### Syntax | |
chmod xxx /path/to/dir/or/file | |
#### Recursive | |
chmod -R xxx /path/to/dir/or/file | |
### Set GUID | |
##### No GUID | |
chmod -R a-s /path/to/dir | |
chmod -R 0xxx /path/to/dir | |
###### example : chmod -R 0640 /home/user/website | |
#### Set UID | |
##### Files will run as the user | |
chmod -R u+s /path/to/dir/ | |
chmod -R 2xxx /path/to/dir | |
#### Set GID | |
##### Any subdir and subfile will have the same group | |
chmod -R g+s /path/to/dir/ | |
chmod -R 4xxx /path/to/dir | |
#### Set GUID | |
##### Set both UID and GID | |
chmod -R a+s /path/to/dir/ | |
chmod -R 6xxx /path/to/dir | |
# Group ownership | |
Change group ownership on files or directories. | |
## Command | |
chgrp | |
## Syntax | |
chgrp -Args group /path/to/dir/or/file | |
### Recursive | |
chgrp -R group /path/to/dir/ | |
# User and group ownership | |
Change user ownership for files and directories | |
## Command | |
chown | |
## Syntax | |
chown -Args user /path/to/dir/or/file | |
chown -Args user:group /path/to/dir/or/file | |
### Recursive | |
chown -R |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment