Answers:
您可以使用以下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
来自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.
显示的数据存储在中/etc/shadow,该文件包含加密的密码。
例如,在上述每个passwd命令之后,状态为:
1:root:$6$............long hash...............::::::
1:root:!$6$........same long hash.............:16478::::::
1:root::16478::::::
一种可能性是通过输入进入/ etc / passwd
grep root /etc/passwd
它应该显示一行开头root:x: ......,其中x表示已加密的密码存储在影子文件中。如果是这种情况,我们可以通过运行
sudo grep root /etc/shadow
(阴影文件需要sudo才能打开!)您应该得到如下所示的开头,结果root:!: ......是!或*表示该帐户已被禁用。后面的任何其他值(不是以!或*开头)root:都表示有效的密码。
man passwd.5和man shadow.5
默认情况下,在安装Ubuntu时,您不应该知道root密码。它存在,但是用户不应该知道。管理员当然可以选择使用来更改密码,sudo passwd但是通常不必这样做,除非您知道自己在做什么以及为什么这么做。
包含有关所有用户密码的信息的文件为,/etc/shadow 并且该文件中的每个条目均已加密。因此,除非攻击者获得了访问您的系统的权限并偷走了该文件,否则他或她将根本无法输入root用户。当然,总有可能,因此,我建议您禁用所有远程访问功能:telnet(默认情况下未启用),ssh,远程桌面等。使用自己的nmap工具并扫描系统,sudo nmap localhost以查看可能打开了哪些端口系统。另外,为自己设置防火墙;ubuntu带有ufw防火墙,该防火墙易于使用并且可以很好地完成工作。
在其他方法中,您可以使用以下方法测试根帐户 sudo -i
在/etc/sudoers文件中,您应该有这样一行:sudo -i。如果您无法以root用户身份登录,则看不到#as提示符,则该帐户已被锁定
Defaults env_reset,timestamp_timeout=30
timestamp_timeout将告诉sudo在30秒后再次要求输入密码,这样您就不会一直以root特权登录。这是保护系统安全的方法之一。
更改root密码的不利影响是,如果您忘记密码或系统上的另一个用户忘记了密码,则您将无权访问root。我不知道任何实例,但是总有可能使系统混乱,因为某些进程以root身份运行,并且如果锁定root帐户,则可能无法正常工作或根本无法工作。
我强烈建议您通读man sudoers,man passwd,老兄。
祝您好运,希望对您有所帮助!