In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about what the passwd utility commands are about in Linux. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Syntax:
# passwd {options} {user_name}
You can use different options in the passwd command, as listed below:
Example 1: change the password of a system user
When you log in with a non-root user, such as when I log in with 'linuxtechi', running the passwd command resets the password of the current logged-in user.
[linuxtechi@linuxworld] $passwd Changing password for user linuxtechi. Changing password for linuxtechi. Current: UNIX password: New password: Retype new password: passwd: all authentication tokens updated successfully. [linuxtechi@linuxworld ~] $
When you log in as a root user and run the passwd command, it resets root's password by default, and if you specify a user name after the passwd command, it resets that user's password.
[root@linuxworld ~] # passwd [root@linuxworld ~] # passwd linuxtechi
Note: the password of the system user is stored in the / etc/shadow file in encrypted form.
Example 2: display password status information
To display the status information of the user's password, use the-S option after the passwd command.
[root@linuxworld] # passwd-S linuxtechi linuxtechi PS 2015-09-200 99999 7-1 (Password set, SHA512 crypt.) [root@linuxworld ~] #
In the above output, the user name is shown in the * fields, the second field shows the password status (PS = password setting, LK = password locked, NP = no password), the third field shows the time when the password was last modified, and the next four fields show the minimum period and * * period for which the password can be changed, the warning period and the length of time the password has not been used.
Example 3: display the password status information of all accounts
In order to display status information for all user passwords, you need to use the "- aS" option in the passwd command, the example is as follows:
Root@localhost:~# passwd-Sa
LCTT Note: different distributions / passwd behave differently. CentOS6.6 did not test successfully, but Ubuntu can.)
Example 4: delete a user's password using the-d option
Use me as an example to delete the password of the 'linuxtechi' user.
[root@linuxworld] # passwd-d linuxtechi Removing password for user linuxtechi. Passwd: Success [root@linuxworld] # [root@linuxworld] # passwd-S linuxtechi linuxtechi NP 2015-09-200 99999 7-1 (Empty password.) [root@linuxworld ~] #
The "- d" option clears the user's password and disables user login.
Example 5: set the password to expire immediately
Using the'- e' option in the passwd command immediately causes the user's password to expire, which forces the user to change the password the next time they log in.
[root@linuxworld] # passwd-e linuxtechi Expiring password for user linuxtechi. Passwd: Success [root@linuxworld] # passwd-S linuxtechi linuxtechi PS 1970-01-01 99999 7-1 (Password set, SHA512 crypt.) [root@linuxworld ~] #
Now try to connect to the host using linuxtechi user SSH.
Example 6: lock the password of a system user
Use the'- l 'option in the passwd command to lock the user's password, which adds "!" to the beginning of the password. When his / her password is locked, the user will not be able to change its password.
[root@linuxworld] # passwd-l linuxtechi Locking password for user linuxtechi. Passwd: Success [root@linuxworld] # passwd-S linuxtechi linuxtechi LK 2015-09-200 99999 7-1 (Password locked.) [root@linuxworld ~] #
Example 7: use the-u option to unlock the user password
[root@linuxworld] # passwd-u linuxtechi Unlocking password for user linuxtechi. Passwd: Success [root@linuxworld] #
Example 8: use the-I option to set inactivity time
Use the-I option in the passwd command to set the inactivity time of the system user. When the password of the user (I am using the linuxtechi user) expires and the user does not change his password after another'n 'day (10 days in my case), the user will not be able to log in.
[root@linuxworld] # passwd-I 10 linuxtechi Adjusting aging data for user linuxtechi. Passwd: Success [root@linuxworld] # [root@linuxworld] # passwd-S linuxtechi linuxtechi PS 2015-09-200 99999 7 10 (Password set, SHA512 crypt.) [root@linuxworld ~] #
Example 9: use the-n option to set the minimum time for password change
In the following example, the linuxtechi user must change the password within 90 days. 0 means that the user can change its password at any time.
[root@linuxworld] # passwd-n 90 linuxtechi Adjusting aging data for user linuxtechi. Passwd: Success [root@linuxworld] # passwd-S linuxtechi linuxtechi PS 2015-09-20 90 99999 7 10 (Password set, SHA512 crypt.) [root@linuxworld ~] #
Example 10: use the-w option to set the warning period before the password expires
The'- w 'option is used to set the warning period for the user in the passwd command. This means that his / her password will expire after n days.
[root@linuxworld] # passwd-w 12 linuxtechi Adjusting aging data for user linuxtechi. Passwd: Success [root@linuxworld] # passwd-S linuxtechi linuxtechi PS 2015-09-20 90 99999 12 10 (Password set, SHA512 crypt.) [root@linuxworld] # Thank you for reading! This is the end of this article on "what are the practical commands for passwd in Linux?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.