-
Notifications
You must be signed in to change notification settings - Fork 0
Linux:Adding a user
You can use the sudo useradd (username) command inside the terminal to add a new user. If you are using OpenSUSE you need to use sudo /usr/sbin/useradd (username) command to add new users because the useradd command is not in the normal location.
When you add a new user Linux will set the home directory to /home/(username) and populate it with the files copied from /etc/skel location. Plus it will add a line to the /etc/passwd file and set the default shell to /bin/bash for the new user.
To view what files will be copied to the home directory when a new user is created input cd /etc/skel and then ls to list the contents of the folder in the terminal.
To view the /etc/passwd file input less /etc/passwd in the terminal.
For each user a line is added to the passwd file in the following format:
username:x:user ID(UID):primary group ID(GID):group list:user information (like phone numbers):home directory location: command/shell
.
For example the steven line (steven:x:1001:1001:drom,lpadmin,sambashare,newgroup:/home/steven:/bin/bash
) from the screen shot above means:
- Username = steven
- Password(x) = encrypted password
- UserID = 1001
- Primary Group ID = 1001
- Groups the user belongs to = drom,lpadmin,sambashare,newgroup
- User Information = None
- Home Directory Location = /home/steven
- Command Shell Location = /bin/bash
The encrypted passwords is stored in the /etc/shadow file and is displayed as an x in the /etc/passwd file.
When you create a new user it will be setup in a locked state. To unlock the user account you have to set a password for that user using the passwd (username) command.
Always Learning
- Home
- Websites
- Linux
- Java
- Gradle
- JUnit
- Database