[root@moban~]#passwdxpleaf
Changingpassword
for
userxpleaf.
Newpassword:
Retypenewpassword:
passwd:allauthenticationtokensupdatedsuccessfully.
If passwd is not followed by a user, the password is created or modified for the current user by default. However, this method is troublesome, because every time you have to ask and enter two passwords, that is, interactive commands are required. Obviously, it cannot be used to modify user passwords in batches, to modify user passwords in batches, use the following method:
[root@moban~]#echo
123456
|passwd--stdinxpleaf
Changingpassword
for
useroldboy.
passwd:allauthenticationtokensupdatedsuccessfully.
This method can avoid interaction, but it also has some disadvantages. When using the history command, the modified password is exposed:
[root@moban~]#history
388
echo
123456
|passwd--stdinxpleaf
Therefore, after using this method to change the password, we need to clear this history:
[root@moban~]#history-d
388
# Clear the row number
388
History input commands
[Root @ moban ~] # History-c # Clear all historical input commands
4) Switch users
[1] root-> common users:
[root@moban~]#whoami
root
[root@moban~]#su-xpleaf
[oldboy@moban~]$whoami
xpleaf
As you can see, you do not need to enter the user password to switch from the root user to the normal user.
[2] normal user-> root:
[oldboy@moban~]$su-root
Password:
[3] common users-> common users:
[oldboy@moban~]$su-test
Password:
We can see that the password is required for switching from a common user to a root user or a common user.
[4] difference between su and su-
Common su:
[root@moban~]#whoami
root
[root@moban~]#suxpleaf
[xpleaf@mobanroot]$
After switching to the xpleaf user, we can see that the [xpleaf @ moban root] $ is followed by root, indicating that the environment variable is the environment variable under the root user. In this case, various problems may occur.
Su -:
[xpleaf@mobanroot]$exit
exit
[root@moban~]#su-xpleaf
[xpleaf@moban~]$
At this time, the environment variable has changed to the environment variable under xpleaf, which is used in the production standard.