博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
centos root密码_如何在CentOS中恢复丢失的root密码
阅读量:2519 次
发布时间:2019-05-11

本文共 2756 字,大约阅读时间需要 9 分钟。

centos root密码

In Linux, when you forget your account password, you can easily reset it using a root account. But when you forget your root account password, then you're in a bad situation.

在Linux中,如果您忘记了帐户密码,则可以使用root帐户轻松地将其重置。 但是,如果您忘记了root帐户密码,那么您的处境很糟。

You can’t reset your root account password using a regular user account as a user account can't perform such tasks in general.

您无法使用常规用户帐户重置根帐户密码,因为用户帐户通常无法执行此类任务。

In this article we’ll be covering how to recover your CentOS root password. So let's see how to do it.

在本文中,我们将介绍如何恢复您的CentOS根密码。 因此,让我们来看看如何做。

如何恢复您的root密码-分步操作 (How to recover your root password - step-by-step)

In CentOS, it’s possible to have the scripts that run from the initramfs debug the shell at certain points, provide a root shell, and continue when that shell exists.

在CentOS中,可以使从initramfs运行的脚本在某些时候调试shell,提供根shell,并在该shell存在时继续运行。

While this is mostly meant for debugging, it can also be used to recover a lost root password.

虽然这主要是为了调试,但也可以用来恢复丢失的root密码。

Follow these steps to recover your lost root password.

请按照以下步骤恢复丢失的root密码。

First, reboot the system.

首先,重新启动系统。

Interrupt the boot loader countdown by pressing any key.

通过按任意键中断引导加载程序的倒计时。

Move the cursor to the entry that needs to be booted.

将光标移动到需要引导的条目。

Press “e” to select that entry. After selecting that entry, the below kernel commands will appear.

按“ e”选择该条目。 选择该条目后,将出现以下内核命令。

In the kernel command line, move the cursor to the line that starts with linux16.

在内核命令行中,将光标移动到以linux16开头的行。

Press the “End” key to move the cursor to the end of it. Type “rd.break” (This will break just before control is handed from the initramfs to the actual system).

按“结束”键将光标移到其末尾。 输入“ rd.break”(这将在从initramfs传递控制权之前中断。 到实际系统)。

Then press “Ctrl+x” to save those changes. The Initramfs debug shell will appear.

然后按“ Ctrl + x”保存这些更改。 将显示Initramfs调试外壳。

Next, we have to provide read and write permissions to /sysroot by typing the below command:

接下来,我们必须通过输入以下命令来提供对/ sysroot的读写权限:

mount -o remount,rw /sysroot/

Now switch into chroot jail.

现在切换到chroot监狱。

chroot /sysroot

In here, /sysroot is treated as the root of the file system tree.

在这里,/ sysroot被视为文件系统树的根。

Next you'll set a new root password.

接下来,您将设置一个新的root密码。

passwd root

And relabel the files.

并重新标记文件。

touch /.autorelabel

Finally, type “exit” twice.

最后,键入两次“退出”。

The first one will exit from the chroot jail.

第一个将从chroot监狱退出。

The next one will exit from the initramfs debug shell and reboots the system.

下一个将从initramfs调试外壳退出并重新启动系统。

Now you can login as root with your updated password.

现在,您可以使用更新后的密码以root用户身份登录。

Please feel free to let me know if you have any questions. You can contact and connect with me on .

如有任何疑问,请随时告诉我。 您可以在与我联系并建立联系。

Thank you for reading.

感谢您的阅读。

Happy Coding!

编码愉快!

翻译自:

centos root密码

转载地址:http://ojhwd.baihongyu.com/

你可能感兴趣的文章
浅谈css(块级元素、行级元素、盒子模型)
查看>>
Ubuntu菜鸟入门(五)—— 一些编程相关工具
查看>>
PHP开源搜索引擎
查看>>
12-FileZilla-响应:550 Permission denied
查看>>
ASP.NET MVC 3 扩展生成 HTML 的 Input 元素
查看>>
LeetCode 234. Palindrome Linked List
查看>>
编译HBase1.0.0-cdh5.4.2版本
查看>>
结构体指针
查看>>
迭代器
查看>>
Food HDU - 4292 (结点容量 拆点) Dinic
查看>>
Ubuntu安装Sun JDK及如何设置默认java JDK
查看>>
[经典算法] 排列组合-N元素集合的M元素子集
查看>>
Codeforces 279D The Minimum Number of Variables 状压dp
查看>>
打分排序系统漫谈2 - 点赞量?点赞率?! 置信区间!
查看>>
valgrind检测linux程序内存泄露
查看>>
Hadoop以及组件介绍
查看>>
1020 Tree Traversals (25)(25 point(s))
查看>>
第一次作业
查看>>
“==”运算符与equals()
查看>>
单工、半双工和全双工的定义
查看>>