Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Passwd command

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Passwd command

The passwd command is used to set the user's authentication information, including user password, password expiration time, and so on. System managers can use it to manage the passwords of system users. Only the administrator can specify the user name, and the average user can only change his or her password.

Grammar

Passwd (option) (parameter)

Option

-d: delete the password and only the system administrator can use it

-f: enforcement

-k: the setting can only be updated after the password expires.

-l: lock the password

-s: lists the information about the password, which can only be used by the system administrator

-u: unlock the locked account.

Parameters.

User name: the user name that needs to set the password.

Example

If an ordinary user executes passwd, he can only change his own password. If you want to create a password for a new user after you create a new user, use the passwd user name, and be careful to create it with the privileges of the root user.

[root@localhost ~] # passwd linuxde / / change or create the password of the linuxde user

Changing password for user linuxde. New UNIX password: / / Please enter a new password

Retype new UNIX password: / / enter again

Passwd: all authentication tokens updated successfully. / / successful

Ordinary users can simply run passwd if they want to change their passwords, for example, the current user is linuxde.

[linuxde@localhost ~] $passwd

Changing password for user linuxde. / / change the password of the linuxde user

(current) UNIX password: / / Please enter the current password

New UNIX password: / / Please enter a new password

Retype new UNIX password: / / confirm the new password

Passwd: all authentication tokens updated successfully. / / the change was successful

For example, if we prevent a user from changing the password, we can use the-l option to lock it:

[root@localhost ~] # passwd-l linuxde / / Lock user linuxde cannot change password

Locking password for user linuxde. Passwd: Success / / locked successfully

[linuxde@localhost ~] # su linuxde / / switch to linuxde user via su; [linuxde@localhost ~] $passwd / / linuxde to change password

Changing password for user linuxde.

Changing password for linuxde

(current) UNIX password: / / enter the current password of linuxde

Passwd: Authentication token manipulation error / / failed, password cannot be changed

Let's take another example:

[root@localhost ~] # passwd-d linuxde / / clear linuxde user password

Removing password for user linuxde. Passwd: Success / / cleared successfully

[root@localhost ~] # passwd-S linuxde / / query linuxde user password status

Empty password. / / empty password, that is, no password

Note: when we clear a user's password, we do not need a password to log in, which should be noted.

Summary

Passwd / / does not follow the parameter to change the password of the current user

Passwd user1 / / change the user's password with the user

Mkpasswd / / tool for automatically generating passwords, included in the expect package

Yum install-y expect / / install the install package

Mkpasswd / / can generate an irregular string with a default length of 9 without arguments

Mkpasswd-l 12 / / specify a password length of 12

Mkpasswd-l 12-s 0 / / length 12 and does not contain "0"

Mkpasswd-l 12-s 0-d 4 / / length 12 and does not contain "0" and contains 4 numbers

Mkpasswd-l 12-s 0-d 4-C 5 / / length 12 and does not contain "0" and contains 4 numbers and 5 capital letters

Mkpasswd-l 12-s 0-d 4-c 5 / / length 12 and does not contain "0" and contains 4 numbers and 5 lowercase letters

Passwd-- stdin user1 / / set the password in clear text, you only need to enter it once. Suitable for use in scripts

For example: # echo "123456" | passwd-- stdin user1 / / set a password of 123456 for user user1

# echo "123456" | passwd-- stdin / / set a password of 123456 for root users

Ordinary users need to know their old passwords to change their passwords, but root users don't need them.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report