File permissions

This is the approved revision of this page, as well as being the most recent.


You can change file permissions with:

$ chmod [r][g][u] [file]

[r] = number for root permissions, [g] = number for group permissions and [u] = number for user permissions.

7 = 4+2+1 (read/write/execute)
6 = 4+2 (read/write)
5 = 4+1 (read/execute)
4 = 4 (read)
3 = 2+1 (write/execute)
2 = 2 (write)
1 = 1 (execute)


You can change owner and group of file with:

# chown [user]:[group] [file]

You can change owner of folder and files inside recursively with:

# chown -R [user]:[group] [folder]


You can add user to group with:

# gpasswd -a [user] [group]

You can remove a user from a group with:

# gpasswd -d [user] [group]


You can add a new user with:

# useradd -g users -G wheel,audio,portage -m [user]
# passwd [user]

You can delete a user with:

# userdel [user]


You can add a new group with:

# groupadd [group]

You can delete a group with:

# groupdel [group]