CHOWN |
Change user and group ownership of files and folders |
Change the owner user of a file or folder |
chown username path/to/file |
Change the owner user and group of a file or folder |
chown user:group path/to/file |
Recursively change the owner of a folder and its contents |
chown -R user path/to/folder |
Change the owner of a symbolic link |
chown -h user path/to/symlink |
Change the owner of a file or folder to match a reference file |
chown --reference=path/to/reference_filepath/to/file |
CHGRP |
Change group ownership of files and folders. |
Change the owner of a file or folder |
chgrp group path/to/file |
Recursively change the owner of a folder and its contents |
chgrp -R group path/to/folder |
Change the owner of a symbolic link |
chgrp -h user path/to/symlink |
Change the owner of a file/folder to match a reference file |
chgrp --reference=path/to/reference_file path/to/file |
CHMOD |
Change the access permissions of a file or directory |
Give the user who owns a file the right to e[x]ecute it |
chmod u+x file |
Remove executable rights from the group |
chmod g-x file |
Give the user rights to read and write to a file or directory |
chmod u+rw file |
Give all users rights to read and execute |
chmod a+rx file |
Give others (not in the file owner’s group) the same rights as the group |
chmod o=g file |
User, Group, Other |
'u' | 'g' | 'o' |
Read, Write, Execute |
'r' | 'w' | 'x' |
'+' | '-' | '=' |
Add, Revoke, Set |
Octal |
0 = None, 1 = execute only, 2 = write only, 3 = write and execute, 4 = read only, 5 = read and execute, 6 = read and write, 7 = read, write and execute (full permission) |