Learn GNU/Linux Commands (9): Group - groups, id, gpasswd, groupadd, groupmod, groupdel
In GNU/Linux, a user belongs to at least one group. A user can belong to multiple groups.
Each group has its own policy on accessing files in the system.
Users in the sudoer's group have administration privileges as root. For Fedora/CentOS/RHEL, the sudoer's group is named "wheel". For other distros, it may be named "sudo" by default.
Information about groups in the system is normally stored in "/etc/group".
Display Group membership
groups [USER]
Display which groups USER belongs to. If USER is omitted, the default is the current user. For example:
[Texpion@com ~]$ groups root
root: root
The result is in the following format:USER: GROUP...
id [USER]
Display user and group information for USER, if USER is omitted, for the current user. For example:
[Texpion@com ~]$ id root
uid=0(root) gid=0(root) groups=0(root)
Add a user to a group
gpasswd -a USER GROUP
Add USER to GROUP. If USER belongs to other groups already, GROUP becomes its secondary group.
"gpasswd" option:
- -a, --add USER: Add USER to GROUP
Remove a user from a group
gpasswd -d USER GROUP
Remove USER from GROUP.
"gpasswd" option:
- -d, --delete USER: remove USER from GROUP.
Make a New Group
groupadd GROUP
Change a Group's Name
groupmod -n NEW_NAME OLDNAME
"groupmod" option:
- -n, --new-name NEW_NAME: change the name to NEW_NAME.
Delete a Group
groupdel GROUP
Comments
Post a Comment