_ _ ___ | |__ __ _ _______ | |_ / _ \| '_ \ / _` |_ / _ \| __| | (_) | | | | (_| |/ / (_) | |_ \___/|_| |_|\__,_/___\___/ \__|
| ohazot | docs | links | dev | conf | txt |
| es | en |
| mdoc file |
| search |
permissions —
assign and modify file
permissions.
TYPES
Permission types can be an octal number or an symbols.
| Type | | Octal | | Symbol |
| None | | 0 | | |
| Execution | | 1 | | x |
| Write | | 2 | | w |
| Read | | 4 | | r |
Example
- Write (2) + Read (4) = 6
- w+r
ASSIGNMENT
When a user creates a file or directory, it's assigned as the owner, and its main group is assigned as the owner group.
Format
The permissions are displayed with the following format: owner, group owner, other groups, all users. Example:
$ whoami user1 $ groups users $ ls -l -rwxr-xr-- 1 user1 users .... file1
- user1 is the owner and has permissions to read, write and execute.
- The users corresponding to the group users have permissions to read and execute.
- Users from other groups have permissions to read.
- The corresponding octal value is 754.
COMMANDS
Important
Users can modify permissions on files if they have write permissions.
chown
Modifies the owner of a file or directory.
| Modify user | : chown username filename |
| Modify user and group | : chown username:groupname filename |
chmod
Changes the permissions on a file or directory as explained in Sx TYPES. To assign (=), add (+) or remove (-) permissions, the who symbols can be used for user (u), group (g) or other (o).
| Change | | Command |
| Octal assignment | | chmod 755 file |
| Add write permissions for group | | chmod g+w file |
| Assign read and write permissions to others | | chmod o=rw file |
| Remove read permission to other groups and users | | chmod o-r file |
chgrp
chgrp -R GROUP DIRECTORYTODO
- Add sticky bit and execute bit.