Home  >  Article  >  Operation and Maintenance  >  How to create a new user and set a password in linux

How to create a new user and set a password in linux

青灯夜游
青灯夜游Original
2021-02-19 11:13:5794561browse

In Linux, you can use the "useradd username" command to create a new user; then use the "passwd username" command to set a password for the created user. You need to enter the password twice to ensure that the password is correct. . The newly created user will create a username directory under "/home".

How to create a new user and set a password in linux

The operating environment of this tutorial: Red Hat Enterprise Linux 6.1 system, Dell G3 computer.

linuxCreate a new user and set a password

Create user testuser

useradd testuser

Set a password for the created user testuser

passwd testuser

Note: The newly created user will create a user directory testuser under /home

  • usermod --help Modify the relevant parameters of this command for the user

  • userdel testuser Delete user testuser

  • ##rm -rf testuser Delete the directory where user testuser is located

The above commands can only be used by the root account. If you don’t know where the above commands are in your system, you can use the following command to find the path:

locate useradd

Related recommendations: "

Linux Video Tutorial"

After creating a new user, the relevant information of the new user will be added to the passwd file in the etc directory

Note: In order to take a screenshot, I used the

tail -3 passwd command to display only the last three lines of information in the file (which is also the information I am concerned about)

Mutual switching of users under the command line window:


su 用户名

Description: su is the abbreviation of switch user, which means user switching

from the new user state Enter "exit" below to return to the previous user state


Add and delete user groups:

  • groupadd testgroup Adding a group

  • groupdel testgroup Deleting a group

Description: Group Added and deleted information will be reflected in the group file in the etc directory.

If you set the shutdown time within 10 minutes and don’t want to shut it down anymore, you can use

ctrl c to terminate the shutdown command.

For more programming-related knowledge, please visit:

Programming Teaching! !

The above is the detailed content of How to create a new user and set a password in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn