KandZ – Tuts

We like to help…!

Linux CLI 18 🐧 id, chmod and umask commands

id is used to display information about a user
getting information for the current user
getting information for specific user
getting the user ID for specific user
getting the group ID for specific user
getting the name for a specific user
getting all groups for a specific user

chmod changes the permissions of a file or a directory
only the owner or the superuser is allowed to do that
youcan change the permissions with 2 ways
1 → by symbolic representation
symbolic representation example
2 → by octal number representation
octal number representation example

chmod symbolic representations explanation
u → owner g → group o → others → add permission - → remove permission = → set permissions

r → readable w → writable x → executable
s → set user id S → set group id
u+rwx → add to the owner read, write and execute permissions
g-wx → removes from the group write and execute permissions
o=rx → set for the others read and execute permissions

chmod octal number representation
there are 3 digits, like 644
1st → for the owner(u) 2nd → for the group(g) 3rd → for the other(o)
0 → no permissions(---) 1 → execute permission(--x) 2 → write permission(-w-)
3 → write and execute permissions(-wx) 4 → read permission(r--)
5 → read and execute permissions(r-x) 6 → read and write permissions(rw-)
7 → read, write and execute permissions(rwx)
sets 640 → read and execute for the owner, read permissions for the group and no permissions for the rest

umask determines the default permissions applied to new files/directories
gets the current default permission
chaging to 0000, no file or directory will have any restrictive permissions by default
changing back to 0022
to understand the new permission just subtract
files 666-022 = 644
directories 777-022=755
echo "umask new_mask" →→ ~/.bashrc → adds a new mask to .bashrc and you it will be permanent

Leave a Reply