Add & Delete Groups in Linux
Last modified: 2023-10-30
We can easily add/delete groups in Linux using `groupadd`, `groupdel` commands.
# Add a group groupadd <group> # Delete a group groupdel <group>
# -a: Append the user to the specific group # -G: Group usermod -a -G <group> <user> # Change user's primary group # -g: GID usermod -g <group> <user>
Ussers who belong to
sudo group can execute commands with
To add a user to the
sudo group, run the following command.
usermod -a -G sudo <user>
After that, we can check the result.
# Switch to target user su <user> # List the user's privileges. sudo -l
We can see groups exist in Linux using the following commands.
cat /etc/group groups # List groups where the specific user in groups <user>