Add Users to Groups in Linux: A Step-by-Step Guide
Adding Existing Users to a Group
To add an existing user to a secondary group, use the following command:
``` sudo usermod -aGReplace
with the name of the group you want to add the user to, and
with the username of the user you want to add.
Adding New Users to a Group
To add a new user to an existing group or create a new group and then add the user, follow these steps:
Creating a New Group
To create a new group, use the following command:
``` sudo groupaddAdding a New User to an Existing Group
To add a new user to an existing group, use the following command:
``` sudo useradd -GAdding a New User to a New Group
To add a new user to a new group, create the group first using the command provided above, then add the user using the following command:
``` sudo useradd -GConclusion
Managing groups and users in Linux is essential for system administration. By following the steps outlined in this guide, you can effectively add users to groups, ensuring proper privilege management and enhanced security.
Comments