Zig*_*gnd 37 command-line root password
可能重复:
如何知道我的 root 密码?
我想为 root 定义一个密码,以便我可以su
直接使用,而不必在它前面加上sudo
. 因为我也想以 root 身份登录。
那么如何为root用户设置密码呢?
Zig*_*gnd 57
警告:直接以root身份登录就像玩火一样,因为一个小小的错误就足以丢失关键数据或使您的系统无法启动。请注意,如果您以root身份登录桌面环境,它们也会无法正常运行。
请参阅这些问题以了解为什么
sudo
首选以及默认情况下禁用 root-login背后的原因:
您可能已经注意到,您无法在 Ubuntu 上以 root 身份登录,这是因为 root 实际上没有设置密码。
输入以下命令:
sudo passwd
Run Code Online (Sandbox Code Playgroud)
系统将提示您输入当前用户的密码,然后是您要为 root 设置的密码。提示的消息应类似于以下内容:
[sudo] password for <username>: <Type your user password and press return>
Type new UNIX password: <Type the root password you want>
Retype new UNIX password: <Retype the root password you chose in the previous prompt>
Run Code Online (Sandbox Code Playgroud)
之后将出现以下消息:
passwd: password updated successfully
Run Code Online (Sandbox Code Playgroud)
如果上述消息出现在您的终端上,您现在可以从当前用户输入以下命令以 root 身份输入:
su
Run Code Online (Sandbox Code Playgroud)
系统将提示您输入您设置的 root 密码。就是这样!
我如何在 ubuntu 上创建根目录:首先我这样做
sudo -i
Run Code Online (Sandbox Code Playgroud)
然后
passwd
Run Code Online (Sandbox Code Playgroud)
正如@Zignd 提到的,经典消息将出现:
Type new UNIX password: [Type the root password you want]
Retype new UNIX password: [Retype the root password you chosen before]
passwd: password updated successfully
Run Code Online (Sandbox Code Playgroud)
然后我可以将其su
用作普通根帐户...