In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
The editor today takes you to understand how to understand the passwd command of the Linux system. The knowledge points in the article are introduced in great detail. Friends who feel helpful can browse the content of the article with the editor, hoping to help more friends who want to solve this problem to find the answer to the problem. Follow the editor to learn more about "how to understand the passwd command of the Linux system".
The original name of passwd means password, and it mainly modifies the password of system users in Linux system.
How to use the passwd command in Linux system:
Syntax:
# passwd {options} {user_name} 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 will reset the password of the current logged-in user.
[linuxtechi@linuxworld] $passwd Changing password for user linuxtechi.a 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 the root password by default, and if you specify a user name after the passwd command, it resets the 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 a user's password, use the-S option after the passwd command.
[root@linuxworld ~] # passwd-S linuxtechilinuxtechi PS 2015-09-200 99999 7-1 (Password set, SHA512 crypt.) [root@linuxworld ~] # in the above output, the first field shows the user name, the second field shows the password status (PS = password setting, LK = password locked, NP = no password), and the third field shows the time when the password was last changed The next four fields show the minimum and maximum period for which the password can be changed, the warning period, and the length of time the password has not been used.
Example 3: to display the password status information of all accounts, you need to use the "- aS" option in the passwd command in order to display the password status information of all users. 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: use the-d option to delete the user's password. Use me as an example to delete the password of the 'linuxtechi' user.
[root@linuxworld ~] # passwd-d linuxtechiRemoving password for user linuxtechi.passwd: Success [root@linuxworld ~] # [root@linuxworld ~] # passwd-S linuxtechilinuxtechi NP 2015-09-200 99999 7-1 (Empty password.) [root@linuxworld ~] # "- d" option clears the user password and disables user login.
Example 5: setting the password to expire immediately using the'- e' option in the passwd command will immediately expire the user's password, which will force the user to change the password the next time he logs in.
[root@linuxworld ~] # passwd-e linuxtechiExpiring password for user linuxtechi.passwd: Success [root@linuxworld ~] # passwd-S linuxtechilinuxtechi PS 1970-01-01 99999 7-1 (Password set, SHA512 crypt.) [root@linuxworld ~] # now try to connect to the host using the linuxtechi user SSH.
Example 6: locking the password of a system user uses the'- l 'option in the passwd command to lock the user's password, which adds "!" at 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 linuxtechiLocking password for user linuxtechi.passwd: Success [root@linuxworld ~] # passwd-S linuxtechilinuxtechi 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 linuxtechiUnlocking password for user linuxtechi.passwd: Success [root@linuxworld ~] # example 8: use the-I option to set inactivity time in the passwd command The-I option is used 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 linuxtechiAdjusting aging data for user linuxtechi.passwd: Success [root@linuxworld ~] # [root@linuxworld ~] # passwd-S linuxtechilinuxtechi 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, linuxtechi users must change their password within 90 days. 0 means that the user can change its password at any time.
[root@linuxworld ~] # passwd-n 90 linuxtechiAdjusting aging data for user linuxtechi.passwd: Success [root@linuxworld ~] # passwd-S linuxtechilinuxtechi 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 password expiration. The'- w' option is used to set the warning period for users in the passwd command. This means that his / her password will expire after n days.
[root@linuxworld] # passwd-w 12 linuxtechiAdjusting aging data for user linuxtechi.passwd: Success [root@linuxworld] # passwd-S linuxtechilinuxtechi PS 2015-09-20 90 99999 1210 (Password set, SHA512 crypt.) [root@linuxworld] # Thank you for reading. That's all about "how to understand passwd commands in the Linux system". Friends who learn to learn, let's get started. I believe that the editor will certainly bring you better quality articles. Thank you for your support to the website!
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.