The creation of Linux users is different from that of windows systems. Here we describe the commands for creating users in Linux. This includes creating users, changing passwords, changing information, and creating groups.
Command 1 for creating a user in Linux:Create a new user
The useradd command can also be used to create a user account. The command format is as follows:
Common options of the useradd command
-D. Set the logon directory for the new user.
-E: set the end date of the new user. The date format is MM/DD/YY.
-F the account will be permanently suspended several days after it expires. When the value is 0, the account is immediately suspended. If the value is-1, this function is disabled. The default value is-1.
-G: Add new users to a group
-G adds new users to a new group. Each group is separated by commas (,) and cannot contain blank characters.
-S: Specify the logon Shell for the new user
-U: Set the ID of the new user.
After a new user is created, the user information will be added to the/etc/passwd file in the following format:
User name: [Password]: [UID]: [GID]: [identity description]: [main directory]: [Login Shell 〕
The fields are divided into seven parts by the colon.
Because the UID and GID smaller than 500 are generally reserved by the system and do not need to be used as a sign for common users and groups, the newly added users and groups are generally UID and GID greater than 500.
For example, run the following command:
- 〔root@localhost root〕# useradd user1
A user named userl will be created, which has been introduced about user management commands and will not be described here.
The result of executing the useradd command.
Command 2 for creating a user in Linux:Set and modify the User Password passwd
The passwd command is used to set and modify user commands. Only super users and users can change their own passwords. Other common users do not have the right to change the passwords of other users. The command is as follows:
# Passwd (user name 〕
To avoid being noticed when you enter a password, Linux does not use a password similar to Windows to echo the password (displayed as *). Therefore, these characters cannot be entered. For example, you can use the following command to set a password for the newly created userl User:
- 〔root@localhost root〕# passwd user1
Enter the password twice according to the system prompt. The system will display the following:
Passwd: all authentication tokens updated successfully
Indicates that the password is successfully modified. The creation of a user is only completed after the user has set a password. Otherwise, the user cannot log on with the user name.
Modify user information usermod
Linux User Creation command 3: usermod commandUsed to modify user information
The command format is as follows:
# Usermod [Options] [user name 〕
Common Command Options
-D. Update the user's new logon directory.
-E: set the end date of the new user. The date format is MM/DD/YY.
-F the account will be permanently suspended several days after it expires. When the value is 0, the account is immediately suspended. If the value is-1, this function is disabled. The default value is-1.
-G: Updates new users to join the group.
-G defines a user as a group member. Each group uses "?" Separated, cannot contain blank characters
-L change the name of the user during login, and the user directory name will be changed to a new name.
-S specifies the New User Shell
-U user ID value, which must be a unique ID value. The userID of the document directory used under the user directory will be automatically changed. Manually change the document directory that is placed outside the support directory.
For example, the following command modifies user information:
- 〔root@localhost root〕# usermod –d/home/user2 –s/bin/bash user2
Set the main directory path of user2 to/home/user1 and the Shell to/usr/bin/gcc.
Generally, The usermod command modifies the user account information by referring to the command instructions. However, usermod does not allow you to change the name of an online user account. Therefore, when you use usermod to change the user account information, you must confirm that this user account did not execute any program on the computer.
Create a user in Linux Command 4: Create a group groupadd
The groupadd command is used to create a new user group. The command format is as follows:
# Groupadd [Option] [user name 〕
Common options include:
-G: GID value. Unless the-o parameter is used, the value must be unique and cannot be the same. The value cannot be negative.
By default, the GID value is increased at least 500. Traditionally, 0-499 is reserved for system accounts.
-F: an existing group account is added. The system displays an error message and ends groupadd.
In this case, the Group will not be added. In this case, the system will not be added once ). You can also add the-g option. When you add a GID, the GID does not need to be a unique value. You do not need to add the-o parameter, the created group displays the created result adding a group as neither-g or-o options were specified. This is an additional option added by Red Hat Linux.
- Linux Xsupplicant package installation Description
- Fedora skin uses the character pair.
- Linux Makefile
- In-depth discussion on Linux partition Solutions
- 1/5 Small and Medium-Sized Enterprises accelerate the Windows 7 upgrade process