In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "introduction to the usage of passwd commands in Linux system". The explanation in this article is simple and clear, and is easy to learn and understand. Please follow the editor's train of thought to study and learn "introduction to the usage of passwd commands in Linux system".
Let's review the basic usage of the passwd command:
The Linux passwd command is used to change the user's password
Grammar
Passwd [- k] [- l] [- u [- f]] [- d] [- S] [username]
Required parameters:
-d delete password
-f Enforcement
-k updates can only be sent after expiration
-l stop using the account
-S displays password information
-u enable accounts that have been stopped
-x set the period of validity of the password
-g modify group password
-I stop the user account after expiration
Select parameters:
-- help displays help information
-- version displays version information
Example
Modify a user's password
The code is as follows:
# passwd w3cschool / / set the password of the w3cschool user
Enter new UNIX password: / / enter a new password. The password entered has no echo.
Retype new UNIX password: / / confirm password
Passwd: password updated successfully
#
Display account password information
The code is as follows:
# passwd-S w3cschool
W3cschool P 05Compact 13 Compact 2010 0 99999 7-1
Delete user password
The code is as follows:
# passwd-d lx138
Passwd: password expiry information changed.
OK, let's take a look at the actual application:
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.
The code is as follows:
[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.
The code is as follows:
[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.
The code is as follows:
[root@linuxworld] # passwd-S linuxtechi
Linuxtechi 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), the third field shows the time when the password was last modified, and 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: 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:
The code 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.
The code is as follows:
[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.
The code is as follows:
[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.
The code is as follows:
[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
The code is as follows:
[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.
The code is as follows:
[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.
The code is as follows:
[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.
The code is as follows:
[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 your reading. the above is the content of "introduction of passwd command usage in Linux system". After the study of this article, I believe you have a deeper understanding of the introduction of passwd command usage in Linux system, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.