_ _
___ | |__ __ _ _______ | |_
/ _ \| '_ \ / _` |_ / _ \| __|
| (_) | | | | (_| |/ / (_) | |_
\___/|_| |_|\__,_/___\___/ \__|
permissions —
assign and modify file
permissions
Permission types can be an octal number or an symbols.
| Type |
|
Octal |
|
Symbol |
| None |
| 0 |
| |
| Execution |
| 1 |
| x |
| Write |
| 2 |
| w |
| Read |
| 4 |
| r |
Permissions can be assigned by adding the octal values or assigning the symbols.
| - Write (2) + Read (4) = 6 |
| - w+r |
When a user creates a file or directory, it's assigned as the
owner, and its main group is assigned as the owner group.
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. |
(back to top)
Users can modify permissions on files if they have write
permissions.
Modifies the owner of a file or directory.
| Modify user |
: chown username filename |
| Modify user and group |
: chown username:groupname filename |
To modify recursively, use -R.
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 |
When using the octal value or assigning using =, the previous permissions are
overwritten.
(back to top)
| - Translate to Spanish. |
| - Add sticky bit and execute bit. |