"Linux system Optimization" User Management Basics

Source: Internet
Author: User

1) View Current user

[[Email protected] ~] #whoamiroot

2) Add user

[[Email protected] ~] #useradd xpleaf

Or

[[Email protected] ~] #adduser xpleaf

3) Create a password for the user

[Email protected] ~]# passwd xpleafchangingpassword for user xpleaf. New Password:retype newpassword:passwd:allauthentication Tokens updated successfully.

If the user is not received after passwd, the default is to create or modify the password for the current user. But this method is more troublesome, because every time to ask and enter two password, that is, the need for interactive commands, obviously can not be used to bulk modify the user password, if you need to bulk modify the user password, use the following method:

[[Email protected] ~] #echo 123456|passwd--stdin xpleafchangingpassword for user oldboy.passwd:allauthentication tokens Updated successfully.

Using this method avoids the interaction, but there are drawbacks to using this method, and when the history command is used, the modified password is exposed:

[[Email protected] ~] #history 388 echo 123456|passwd--stdin xpleaf

To do this, after you modify the password using this method, we need to clear the history:

[[Email protected] ~] #history-D 388 #清除行号为388的历史输入命令 [[email protected] ~] #history –c #清除所有的历史输入命令

4) Switch User

"1" root-> Ordinary users:

[[Email protected] ~] #whoamiroot [[email protected] ~] #su-xpleaf [[Email protected]~]$ whoamixpleaf

As you can see, switching from the root user to a normal user does not require a user password.

"2" Ordinary user->root:

[Email protected]~]$ Su-rootpassword:

"3" Ordinary user, ordinary User:

[Email protected]~]$ Su-testpassword:

You can see that the switch between a normal user and a root user or a normal user requires a password.

The difference between "4" Su and su–

General SU:

[[Email protected] ~] #whoamiroot [[email protected] ~] #su xpleaf[[email protected] root]$

Although switching to the xpleaf user, the observation can be found in [[email protected] root]$ in the back of the root, that is, the environment variable at this time or under the root user environment variables. In this case, a variety of problems may arise.

su-:

[[email protected] root]$ Exitexit[[email protected] ~] #su-xpleaf[[email protected]~]$

At this point the environment variable has been changed to the environment variable under Xpleaf, which is the method of use in the production standard.


This article is from the "fragrant fluttering leaves" blog, please make sure to keep this source http://xpleaf.blog.51cto.com/9315560/1657689

"Linux system Optimization" User Management Basics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.