Difference between revisions of "File permissions"

From Funtoo
Jump to navigation Jump to search
m
Line 1: Line 1:
== Add user ==
== Add user ==
You can add user with useradd.
<console>
<console>
# 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>
Line 5: Line 6:


== Delete user ==
== Delete user ==
You can delete user with userdel.
<console>
<console>
# userder -r <username>
# userdel -r <username>
</console>
</console>


== List groups ==
== List groups ==
You can list groups with group.
<console>
<console>
$ groups
$ groups
Line 15: Line 18:
</console>
</console>


== List users ==
== Add or remove user from group ==
<console>
You can add or remove user from group with gpasswd.
$ users
</console>
 
== Add user to group ==
<console>
<console>
# gpasswd -a <user> <group>
# gpasswd -a <user> <group>
</console>
== Remove user from group ==
<console>
# gpasswd -d <user> <group>
# gpasswd -d <user> <group>
</console>
</console>


== Add new group ==
== Create new group ==
You can create new group with groupadd.
<console>
<console>
# groupadd <group>
# groupadd <group>
Line 36: Line 32:


== Delete group ==
== Delete group ==
You can also delete group with groupadd.
<console>
<console>
# groupdel <group>
# groupdel <group>

Revision as of 09:06, 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 -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 = 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>