Create user/set password/delete user

serial number

Order

effect

illustrate

01

useradd -m -g group new user name

add new user

-m Automatically create the user's home directory

-g specifies the group the user is in, otherwise a group with the same name will be created.

02

passwd username

set user password

If it is an ordinary user, use passwd directly

You can change your account password

03

userdel -r username

delete users

-r will automatically delete the user's home directory

04

cat /etc/passwd | grep username

Confirm user information

After creating a new user, the user information will be saved in the /etc/passwd file

hint:

When creating a user, if you forget to add the -m option to specify the home directory of the new user, the easiest way is to delete the user and recreate it .

When creating a user, a group name with the same name as the user name is created by default.

User information is stored in the /etc/passwd file.

passwd file:

The /etc/passwd file stores user information, 7 pieces of information composed of 6 semicolons, which are

  1. username

  1. password (x indicates encrypted password)

  1. UID (User ID)

  1. GID (group identifier)

  1. User full name or local account

  1. home directory

  1. The shell used for login is after login, the terminal command used by Ubuntu is dash by default

view user information

serial number

Order

effect

01

id[username]

View user UID and GID information

02

who

View a list of all currently logged in users

03

whoami

View the account name of the currently logged in user

Guess you like

Origin blog.csdn.net/weixin_43138792/article/details/129491993