Add User and Set Password in Linux
To add a user and set a password on a Linux system, you can follow these steps:
- Open the terminal window and enter the following command to switch to superuser (root) permissions:
sudo su
- Use the following command to add a new user (for example, with the username newuser):
useradd newuser
- To set a new password for a new user, use the following command:
passwd newuser
The system will prompt you to enter a new password twice to confirm.
- To add new users to other user groups, you can use the following command:
usermod -aG groupname newuser
Please replace “groupname” with the name of the user group you want to add.
- Finally, exit the root superuser privileges.
exit
Now that you have successfully added a new user and set up a password, you can log in to the system using the new user.