Difference between revisions of "File permissions"

Line 1: Line 1:
== chmod ==
+
== Add user ==
You can change file permissions with:
+
 
<console>
 
<console>
$##bl## chmod [r][g][u] [file]
+
###i## useradd -g users -G wheel,portage,audio,video,usb,cdrom,tty -m <username>
 
</console>
 
</console>
[r] = number for root permissions, [g] = number for group permissions and [u] = number for user permissions.
+
 
 +
== Delete user ==
 +
<console>
 +
###i## userder -r <username>
 +
</console>
 +
 
 +
== List groups ==
 +
$##bl## groups
 +
$##bl## groups <username>
 +
 
 +
== List users ==
 +
$##bl## users
 +
 
 +
== Add user to group ==
 +
###i## gpasswd -a <user> <group>
 +
 
 +
== Remove user from group ==
 +
###i## gpasswd -d <user> <group>
 +
 
 +
== Add new group ==
 +
###i## groupadd <group>
 +
 
 +
== Delete group ==
 +
###i## groupdel <group>
 +
 
 +
== File permissions ==
 +
You can change file permissions with chmod.
 +
<console>
 +
$##bl## chmod <r><g><u> <file>
 +
</console>
 +
<r> = number for root permissions
 +
<g> = number for group permissions
 +
<u> = number for user permissions
 
<pre>7 = 4+2+1 (read/write/execute)
 
<pre>7 = 4+2+1 (read/write/execute)
 
6 = 4+2 (read/write)
 
6 = 4+2 (read/write)
Line 13: Line 44:
 
1 = 1 (execute)</pre>
 
1 = 1 (execute)</pre>
  
== chown ==
+
== Change owner and group of file ==
You can change owner and group of file with:
+
You can change owner and group of file with chown.
 
<console>
 
<console>
###i## chown [user]:[group] [file]
+
###i## 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]
+
###i## chown -R <user>:<group> <folder>
</console>
+
 
+
== gpasswd ==
+
You can add user to group with:
+
<console>
+
###i## gpasswd -a [user] [group]
+
</console>
+
You can remove a user from a group with:
+
<console>
+
###i## gpasswd -d [user] [group]
+
</console>
+
 
+
== useradd ==
+
You can add a new user with:
+
<console>
+
###i## useradd -g users -G wheel,audio,portage -m [user]
+
###i## passwd [user]
+
</console>
+
You can delete a user with:
+
<console>
+
###i## userdel [user]
+
</console>
+
 
+
== groupadd ==
+
You can add a new group with:
+
<console>
+
###i## groupadd [group]
+
</console>
+
You can delete a group with:
+
<console>
+
###i## groupdel [group]
+
 
</console>
 
</console>
  
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
 
[[Category:First Steps]]
 
[[Category:First Steps]]

Revision as of 20:52, 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

$##bl## groups $##bl## groups <username>

List users

$##bl## users

Add user to group

      1. i## gpasswd -a <user> <group>

Remove user from group

      1. i## gpasswd -d <user> <group>

Add new group

      1. i## groupadd <group>

Delete group

      1. i## 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>