Show users
# cat /etc/passwd
Show groups
# cat /etc/group
Add user from group
# usermod -a -G [groupname] [username]
or
# gpasswd -a [username] [groupname]
Delete user from group
# gpasswd -d [username] [groupname]
Change Directory owner
# chgrp [groupname] [foldername]
How to change Owner/Group permissions
# chown [username]:[groupname]
should change the ownership and group to what you want.
# chown -R [username]:[groupname] [directory/file]
should change the ownership of the directory, and the entire subtree under it.
Here is a list of what the shorthand represents:
Identities
u — the user who owns the file (that is, the owner)
g — the group to which the user belongs
o — others (not the owner or the owner's group)
a — everyone or all (u, g, and o)
Permissions
r — read access
w — write access
x — execute access
Actions
+ — adds the permission
- — removes the permission
= — makes it the only permission
Note that to create (or delete) a file in a directory, the user or group must have write permission to the directory. And to list a directory, the user or group must have 'x' permission to the directory.
# chmod ug+rwx [directory/file]
# chmod -R ug+rw [directory/file]
might do what you want.
But read the man pages previously recommended to make sure. And be especially careful with -R. Also, never use a '.*' wildcard for this sort of thing. It will do something very bad that you were not expecting.
# chmod ug+rwx [directory/file]
# chmod -R ug+rw [directory/file]
might do what you want.
But read the man pages previously recommended to make sure. And be especially careful with -R. Also, never use a '.*' wildcard for this sort of thing. It will do something very bad that you were not expecting.
References:
https://www.centos.org/docs/4/html/rhel-sbs-en-4/s1-navigating-ownership.html
man chown
man chgrp
man chmod
man chgrp
man chmod
https://tecadmin.net/tutorial/linux/linux-modify-user/
No comments:
Post a Comment