Difference between revisions of "File permissions"

Line 1: Line 1:
 
== Add user ==
 
== Add user ==
 
<console>
 
<console>
###i## useradd -g users -G wheel,portage,audio,video,usb,cdrom,tty -m <username>
+
# useradd -g users -G wheel,portage,audio,video,usb,cdrom,tty -m <username>
 
</console>
 
</console>
  
 
== Delete user ==
 
== Delete user ==
 
<console>
 
<console>
###i## userder -r <username>
+
# userder -r <username>
 
</console>
 
</console>
  
 
== List groups ==
 
== List groups ==
$##bl## groups
+
<console>
$##bl## groups <username>
+
$ groups
 +
$ groups <username>
 +
</console>
  
 
== List users ==
 
== List users ==
$##bl## users
+
<console>
 +
$ users
 +
</console>
  
 
== Add user to group ==
 
== Add user to group ==
###i## gpasswd -a <user> <group>
+
<console>
 +
# gpasswd -a <user> <group>
 +
</console>
  
 
== Remove user from group ==
 
== Remove user from group ==
###i## gpasswd -d <user> <group>
+
<console>
 +
# gpasswd -d <user> <group>
 +
</console>
  
 
== Add new group ==
 
== Add new group ==
###i## groupadd <group>
+
<console>
 +
# groupadd <group>
 +
</console>
  
 
== Delete group ==
 
== Delete group ==
###i## groupdel <group>
+
<console>
 +
# groupdel <group>
 +
</console>
  
 
== File permissions ==
 
== File permissions ==
 
You can change file permissions with chmod.
 
You can change file permissions with chmod.
 
<console>
 
<console>
$##bl## chmod <r><g><u> <file>
+
$ chmod <r><g><u> <file>
 
</console>
 
</console>
 
<r> = number for root permissions
 
<r> = number for root permissions
Line 47: Line 59:
 
You can change owner and group of file with chown.
 
You can change owner and group of file with chown.
 
<console>
 
<console>
###i## chown <user>:<group> <file>
+
# chown <user>:<group> <file>
 
</console>
 
</console>
 
You can change owner of folder and files inside recursively with:
 
You can change owner of folder and files inside recursively with:
 
<console>
 
<console>
###i## chown -R <user>:<group> <folder>
+
# chown -R <user>:<group> <folder>
 
</console>
 
</console>
  
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
 
[[Category:First Steps]]
 
[[Category:First Steps]]

Revision as of 20:56, September 25, 2014

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>