Difference between revisions of "File permissions"

From Funtoo
Jump to: navigation, search
m (fixed formatting)
m (Added info about -r option of userdel)
Line 13: Line 13:
 
You can delete user with userdel.
 
You can delete user with userdel.
  
 +
<console>
 +
# userdel <username>
 +
</console>
 +
 +
{{fancynote|If you want to remove user files as well (home directory and mail spool, use the <code>-r</code> option:
 
<console>
 
<console>
 
# userdel -r <username>
 
# userdel -r <username>
 
</console>
 
</console>
 +
}}
  
 
== List groups ==
 
== List groups ==

Revision as of 10:01, September 27, 2014


Add user

You can add user with useradd.

root # useradd -g users -G wheel,portage,audio,video,usb,cdrom,tty -m <username>

Delete user

You can delete user with userdel.

root # userdel <username>
   Note

If you want to remove user files as well (home directory and mail spool, use the -r option:

root # userdel -r <username>

List groups

You can list groups with group.

user $ groups
user $ groups <username>

Add or remove user from group

You can add or remove user from group with gpasswd.

root # gpasswd -a <user> <group>
root # gpasswd -d <user> <group>

Create new group

You can create new group with groupadd.

root # groupadd <group>

Delete group

You can also delete group with groupadd.

root # groupdel <group>

File permissions

You can change file permissions with chmod.

user $ chmod <r><g><u> <file>

<r> = number for root permissions <g> = number for group permissions <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)

Change owner and group of file

You can change owner and group of file with chown.

root # chown <user>:<group> <file>

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

root # chown -R <user>:<group> <folder>