How to create a user in Linux?
To create a user on Linux, you can use the following command:
- create a new user
sudo adduser username
Replace “username” with the desired username.
- create a new user
sudo useradd username
Replace “username” with the desired username that you wish to create.
- Specify user home directory when creating a user.
sudo useradd -m -s /bin/bash username
The -m option automatically creates the user’s home directory when creating a user, while the -s option specifies the user’s default shell as /bin/bash.
- Specify user groups when creating users.
sudo useradd -g groupname username
Replace ‘groupname’ with the name of the user group to be assigned to the new user.
- Create a password when setting up a user account.
sudo passwd username
Replace “username” with the username for which you want to set a password. You will then be prompted to enter and confirm the password.
Note: The above command needs to be executed with administrator privileges (sudo).