linux更改root密码_如何在Linux中更改root密码

linux更改root密码

Let’s go over the simple commands to change the root password in Linux. Linux root refers to a special type of user account that has complete unrestricted access to the system.

让我们看一下简单的命令来更改Linux中的root密码。 Linux root是指一种特殊类型的用户帐户,该帐户具有对系统的完全不受限制的访问权限。

Think of it as a top government security agent with a high clearance level. Usually, users are not allowed to run certain commands without root-level clearance or privilege as it is called in Linux.

可以将其视为具有较高通关水平的顶级政府安全机构。 通常,不允许用户在没有root级权限或特权的情况下运行某些命令,就像在Linux中那样。

Linux does this so that a user doesn’t accentually run a command that can cause unwanted loss of data. For example, a user can’t modify most of the files in the /etc directory without first gaining root or sudo permissions.

Linux这样做是为了使用户不会过分地运行会导致不必要的数据丢失的命令。 例如,用户必须先获得root或sudo权限,才能修改/ etc目录中的大多数文件。

To display the current user, use the whoami command.

要显示当前用户,请使用whoami命令。

whoamI
whoami
我是谁

使用sudo以root身份运行命令 (Using sudo to run commands as root)

Sudo or ‘Superuser Do’ gives user root privileges. It is used to run a command as the root. This can be done as:

Sudo或“ Superuser Do”赋予用户root特权。 它用于以根用户身份运行命令。 这可以通过以下方式完成:


$ sudo command 

After this, the system will ask the user for the password. After accepting the password the system will run the command.

此后,系统将要求用户输入密码。 接受密码后,系统将运行命令。

在Linux中使用passwd命令更改root密码 (Using the passwd command to change root password in Linux)

To change the password we can use the passwd command.

要更改密码,我们可以使用passwd命令


$ sudo passwd root

After hitting enter. The system will ask you for the existing root password. Type in the password and hit enter. Now the system will ask you to pick a new password. Retype the new password two times for double-checking and press enter.

点击后进入。 系统将询问您现有的root密码。 输入密码,然后按Enter。 现在,系统将要求您选择一个新密码。 再次输入新密码两次以进行再次确认,然后按Enter。

Passwd Change
Passwd Change
密码更改

Output window will inform you upon performing a successful update.

输出窗口将在成功执行更新后通知您。

修改用户密码 (Changing a user’s password)

As a root user, you can change the password of other users in the system. Knowing the name of the user is sufficient to change the password.

作为root用户,您可以更改系统中其他用户的密码。 知道用户名就足以更改密码。


$ passwd user
Changing User Password
Changing User pwd
更改用户密码

In this example, I have created a user and changed the password for the user. I was able to do this without sudo as I am currently the root.

在此示例中,我创建了一个用户并更改了该用户的密码。 我能够在没有sudo的情况下执行此操作,因为我目前是root。

A user can change their own password without root privileges.

用户可以在没有root特权的情况下更改自己的密码。

User Changing Its Own Password
User Changing Its Own Password
用户更改自己的密码

Note that the new password and the old password can’t be similar.

请注意,新密码和旧密码不能相似。

结论 (Conclusion )

Linux requires normal users to use sudo to get root privileges. Linux protects users from making serious unwanted errors by giving certain permissions only to the root user. Access to the root user is password protected. Sudo command gives access to change the root password.

Linux要求普通用户使用sudo来获得root特权。 Linux通过仅向root用户授予某些权限来保护用户避免造成严重的意外错误。 对root用户的访问受密码保护。 sudo命令提供更改根密码的访问权限。

翻译自: https://www.journaldev.com/41310/change-root-password-linux

linux更改root密码

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值