File permissions

Revision as of 20:56, September 25, 2014 by Causes (Talk | contribs)

Add user

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

Delete user

# userder -r <username>

List groups

$ groups
$ groups <username>

List users

$ users

Add user to group

# gpasswd -a <user> <group>

Remove user from group

# gpasswd -d <user> <group>

Add new group

# groupadd <group>

Delete group

# groupdel <group>

File permissions

You can change file permissions with chmod.

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

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

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

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

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