Linux commands (129) - passwd command

1. Introduction command

passwd order to set user authentication information, including user passwords, account lockout, password expiration and so on.

System administrators can use it to manage system user's password, only the administrator can specify a user name, a general user can only change their own passwords.

2. Command Format

passwd [OPTIONS] [USERNAME]

Without any options and parameters directly run passwd represent modify the current user's login password, which is the most common use passwd.

3. Option Description

Note that the long options must be parameters for short options too.

-k, --keep
	保持身份验证令牌不过期
-d, --delete
  删除已命名帐号的密码(仅限 root 用户)
-l, --lock
	锁定指定帐户的密码(仅限 root 用户)。锁定是在密码加密字符串前面加上 ! 使得密码校验不通过。注意,帐户没有完全锁定,用户仍然可以通过其他身份验证方式登录,如 ssh 公钥身份验证
-u, --unlock
	解锁指定账户的密码(仅限 root 用户)
-e, --expire
	终止指定帐户的密码(仅限 root 用户)
-f, --force
	强制执行操作
-x, --maximum=DAYS
	密码的最长有效时限(仅限 root 用户)
-n, --minimum=DAYS
	密码的最短有效时限(仅限 root 用户)
-w, --warning=DAYS
	在密码过期前多少天开始提醒用户(仅限 root 用户)
-i, --inactive=DAYS
	当密码过期后经过多少天该帐号会被禁用(仅限 root 用户)
-S, --status
	报告已命名帐号的密码状态(仅限 root 用户)
--stdin
	从标准输入读取令牌(仅限 root 用户)
-?, --help
  	显示帮助信息并退出
--usage
	显示简要使用信息

4. Common examples

(1) modify the current account for login password.

passwd

Note that we must abide by "complexity, easy to remember, timeliness," the norms set password user password. Simply put, the password is greater than 8, comprising a case letters, numbers and special symbols, and easy to remember and periodic replacement.

(2) modify other user's password, you need administrator privileges.

passwd USERNAME

(3) Lock password specified account, so that the user can not log on with a password. Administrator rights are required.

passwd -l USERNAME

(4) specify the password to unlock the account. Administrator rights are required.

passwd -u USERNAME

(5) terminates the specified account's password, the next time the user login forced to change the password. Administrator rights are required.

passwd -e USERNAME

(6) clear the login password so that users do not need a password to log in. It requires administrator privileges, risky, not recommended.

passwd -d USERNAME

(7) account password status inquiries.

passwd -S dablelv
dablelv PS 2020-03-08 0 90 7 -1 (Password set, SHA512 crypt.)

Display account status information, a total of seven fields, namely the login name, password, last modification time, the password change interval time (0), password expiration (90), the warning time (7), the password is invalid (-1) units are in days.

(8) the minimum and maximum number of days to set a password.

passwd -x 100 -n 30 dablelv

#查看是否设置成功
passwd -S dablelv
dablelv PS 2020-03-08 30 100 7 -1 (Password set, SHA512 crypt.)

(9) the number of days before the password expires began to alert the user.

passwd -w 7 dablelv

references

[. 1] the passwd (. 1) Manual
[2] . [Linux] CSDN step by step to learn Linux - passwd command (85)

Published 519 original articles · won praise 1567 · Views 2.02 million +

Guess you like

Origin blog.csdn.net/K346K346/article/details/104740812