注意:
The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.
Difference between revisions of "File permissions"
Jump to navigation
Jump to search
m |
m (fixed formatting) |
||
Line 1: | Line 1: | ||
__NOTOC__ | |||
== Add user == | == Add user == | ||
You can add user with useradd. | 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 6: | Line 10: | ||
== Delete user == | == Delete user == | ||
You can delete user with userdel. | You can delete user with userdel. | ||
<console> | <console> | ||
# userdel -r <username> | # userdel -r <username> | ||
Line 12: | Line 18: | ||
== List groups == | == List groups == | ||
You can list groups with group. | You can list groups with group. | ||
<console> | <console> | ||
$ groups | $ groups | ||
Line 19: | Line 27: | ||
== Add or remove user from group == | == Add or remove user from group == | ||
You can add or remove user from group with gpasswd. | You can add or remove user from group with gpasswd. | ||
<console> | <console> | ||
# gpasswd -a <user> <group> | # gpasswd -a <user> <group> | ||
Line 26: | Line 36: | ||
== Create new group == | == Create new group == | ||
You can create new group with groupadd. | You can create new group with groupadd. | ||
<console> | <console> | ||
# groupadd <group> | # groupadd <group> | ||
Line 32: | Line 44: | ||
== Delete group == | == Delete group == | ||
You can also delete group with groupadd. | You can also delete group with groupadd. | ||
<console> | <console> | ||
# groupdel <group> | # groupdel <group> | ||
Line 38: | Line 52: | ||
== File permissions == | == File permissions == | ||
You can change file permissions with chmod. | You can change file permissions with chmod. | ||
<console> | <console> | ||
$ chmod <r><g><u> <file> | $ chmod <r><g><u> <file> | ||
</console> | </console> | ||
<r> = number for root permissions | |||
<g> = number for group permissions | <nowiki><r></nowiki> = number for root permissions | ||
<u> = number for user permissions | <nowiki><g></nowiki> = number for group permissions | ||
<nowiki><u></nowiki> = 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) |
Revision as of 09:56, 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 <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>