Linux provides a powerful command-line interface that allows users to manage various system tasks, including managing users and groups. In Linux, a group is a collection of users with standard privileges and permissions. Managing users and groups is essential for system administration and security. In this article, we will discuss removing a user from a group in Linux.
Step 1: List the user’s current groups
Before removing a user from a group, we need to know which groups the user is currently a member of. We can do this using the “groups” command, followed by the username.
Syntax:
groups [username]
Step 2: Remove the user from the group
Once we know which groups the user belongs to, we can remove them from the group using the “gpasswd” command.
Syntax:
sudo gpasswd -d [username] [groupname]
Step 3: Verify the user’s groups
After removing the user from the group, we can verify that the user is no longer a group member. We can again use the “groups” command to list the user’s groups.
Syntax:
groups [username]
Conclusion
Managing users and groups is a critical aspect of Linux system administration. Removing a user from a group can be quickly done using the “gpasswd” command, but it is essential to verify that the user is no longer a member of the group using the “groups” command. By following the steps outlined in this article, you can easily remove a user from a group in Linux, thereby ensuring the security and stability of your system.
📕 Related articles about Linux
- How to restore MBR from backup in Linux
- How to format disk and partition in Linux
- What is Root Login in SSH
- Most Common Utilities to Extract Archives in Linux
- How to recover lost GRUB bootloader in Linux
- How to list directory content in reverse in Linux