nob*_*bru 10 permissions root sudo
我不小心启用(设置)了我的 root 密码(默认情况下它是锁定的),现在我想“撤消”它。我使用了两个命令
sudo usermod -p '!' root
Run Code Online (Sandbox Code Playgroud)
和
sudo passwd -dl root
Run Code Online (Sandbox Code Playgroud)
以该顺序。
如何检查 root 的帐户是否被锁定?
mur*_*uru 18
您可以使用以下passwd命令:
# passwd -S
root P 11/04/2014 -1 -1 -1 -1
# passwd -l root
passwd: password expiry information changed.
# passwd -S
root L 11/04/2014 -1 -1 -1 -1
# passwd -d root
passwd: password expiry information changed.
# passwd -S
root NP 11/04/2014 -1 -1 -1 -1
Run Code Online (Sandbox Code Playgroud)
来自man 1 passwd:
-S, --status
Display account status information. The status information consists
of 7 fields. The first field is the user's login name. The second
field indicates if the user account has a locked password (L), has
no password (NP), or has a usable password (P). The third field
gives the date of the last password change. The next four fields
are the minimum age, maximum age, warning period, and inactivity
period for the password. These ages are expressed in days.
Run Code Online (Sandbox Code Playgroud)
显示的数据存储在/etc/shadow保存加密密码的文件中。
例如,在上述每个passwd命令之后,状态为:
1:root:$6$............long hash...............::::::
1:root:!$6$........same long hash.............:16478::::::
1:root::16478::::::
Run Code Online (Sandbox Code Playgroud)
一种可能性是通过输入查看 /etc/passwd
grep root /etc/passwd
Run Code Online (Sandbox Code Playgroud)
它应该显示一行开始root:x: ......,其中 x 表示加密的密码存储在影子文件中。如果是这种情况,我们通过运行来查看它
sudo grep root /etc/shadow
Run Code Online (Sandbox Code Playgroud)
(影子文件需要 sudo 才能打开!)作为结果root:!: ......,您应该得到如下开头的行,其中!或*表示帐户已被禁用。之后的任何其他值(不以 ! 或 * 开头)root:都表示有效密码。
| 归档时间: |
|
| 查看次数: |
30489 次 |
| 最近记录: |