linux设置su密码,如何设置root密码,以便可以使用su而不是sudo?

问题描述

不用让您在安装过程中为root设置密码,Ubuntu可以将它设置为*(不设密码)并禁用实际的帐户登录,但是即使这样,您仍然可以通过sudo在ubuntu中使用root。

那么如何在Ubuntu上设置root密码呢?

最佳解决思路

Warning: Directly logging in as root is like playing with fire, because one little typo is enough to lose critical data or make your system unbootable. Note that desktop environments will also function incorrectly if you login to them as root.

See these questions for the reasons behind why sudo is preferred and why root-login is disabled by default:

您可能已经注意到,您无法登录Ubuntu上的root帐户,这是因为root实际上没有设置密码。

输入以下命令:

sudo passwd

将显示以下消息:

[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 chosen before]

将显示以下消息:

passwd: password updated successfully

如果以上消息显示在您的终端上,您现在可以通过输入以下内容来使用root特权:

su

然后键入您选择的密码。而已!

否则,从答案的步骤开始,您可能输入了错误的内容。

次佳解决思路

如果您在阅读问题中的警告后仍想使用su,则无需设置root密码。只需执行sudo su,您便会使用常规密码。

第三种解决思路

我在ubuntu上创建根的操作:首先,我执行此操作

sudo -i

然后

passwd

正如@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

然后我可以将su用作普通的根帐户…

参考资料

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值