Linux_ create user

Create a user named hello and specify /home/hello as the root directory

useradd -d /home/hello -m hello 

Set the password, the password will be entered twice, once to set the password, once to confirm the password, the two passwords must be entered the same

passwd hello

Common parameter meanings of useradd

-d

Specify the home directory when the user logs in. If not set, the system defaults to /home/<username>

-D

Change the default value.

-e

Specify the expiration date of the account, the date format is MM/DD/YY, for example, 06/30/12. The default is permanently effective.

-f

Specifies how many days after the password expires the account will be closed. If it is 0, the account will be disabled immediately; if it is -1, the account will always be available. The default value is -1

-g

Specifies the groups the user belongs to

-G

Specifies additional groups the user belongs to.

-m

Automatically create the user's login directory.

-M

Do not automatically create user login directories.

-n

Cancel the creation of the group with username.

-r

Create a system account.

-s

Specify the shell used by the user after logging in. The default is /bin/bash.

-u

Specifies the user ID number. This value must be unique within the system. 0~499 are reserved for system user accounts by default, so the value must be greater than 499.

The account created by using the useradd command is actually saved in the /etc/passwd text file

Create a new user login prompt "bash-4.2$"

The newly created user displays "-bash-4.2$" when logging in, instead of the display method of "user@hostname+path". The reason for this problem is that when adding a common user, the two environment variable files .bash_profile and .bashrc are lost in the user's home directory.

cp /etc/skel/.bashrc  /home/username
cp /etc/skel/.bash_profile   /home/username

Guess you like

Origin blog.csdn.net/weixin_40877388/article/details/129789442