To create a user account on a Linux system and add it to a specific group, you can use the useradd
command.
For example, to create a user account named user1
and add it to the group1
group, you can use the following command:
sudo useradd -g group1 user1
This will create a new user account user1
and add it to the group1
group.
Alternatively, you can use the adduser
command to create a user account and add it to a group. For example, to create a user account named user1
and add it to the group1
group, you can use the following command:
sudo adduser --ingroup group1 user1
This will create a new user account user1
and add it to the group1
group.
After creating the user account, you can set a password for the account using the passwd
command. For example, to set the password for the user1
account, you can use the following command:
sudo passwd user1
This will prompt you to enter and confirm the password for the user1
account.
Note: You can use the
groups
command to view the groups that a user belongs to. For example, to view the groups that theuser1
user belongs to, you can use the following command:
groups user1