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 Twitter.

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

Thank you for reading.

感谢您的阅读。

Happy Coding!

编码愉快!

翻译自: https://www.freecodecamp.org/news/how-to-recover-your-lost-root-password-in-centos/

centos root密码

centos root密码_如何在CentOS中恢复丢失的root密码相关推荐

  1. java对密码进行加密的方法_如何在JAVA中使用MD5加密对密码进行加密

    如何在JAVA中使用MD5加密对密码进行加密 发布时间:2020-11-25 17:12:40 来源:亿速云 阅读:118 作者:Leah 本篇文章为大家展示了如何在JAVA中使用MD5加密对密码进行 ...

  2. linux关闭root权限管理,如何在Ubuntu中启用和禁用root帐户?

    在Ubuntu Linux中,出于安全原因,默认情况下是禁用root帐户的.下面本篇文章就来带大家了解一下在在Ubuntu中启用和禁用root帐户的方法,希望对大家有所帮助. Sudo用户 Ubunt ...

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

    linux更改root密码 Let's go over the simple commands to change the root password in Linux. Linux root ref ...

  4. centos 配置证书_如何在CentOS 8上设置和配置证书颁发机构(CA)

    centos 配置证书 介绍 (Introduction) A Certificate Authority (CA) is an entity responsible for issuing digi ...

  5. linux中更改用户密码_如何在Linux中更改用户密码

    linux中更改用户密码 In this tutorial, we will focus on how you can change a user's password in Linux. We wi ...

  6. su命令切换到root用户_如何在Linux中使用su命令成为超级用户或root?

    su命令切换到root用户 Linux provides root account as superuser or Administrator. As root account has all pri ...

  7. wordpress默认密码_如何在WordPress中为新用户设置默认管理员配色方案

    wordpress默认密码 One of the most talked about feature of WordPress 3.8 is the new admin interface. It i ...

  8. chrome 保存密码_如何在Chrome中管理保存的密码

    chrome 保存密码 Google Chrome comes with a handy password manager already built in. You can have your br ...

  9. mac删除恢复分区|如何在Mac中恢复丢失的分区

    始终存在这样的情况:Mac中的文件丢失,被错误删除或者只是丢失.分区也是如此.Mac中的分区也可能丢失或删除,这会让您失去保存在其上的全部文件.导致分区丢失的常见原因有: 硬盘崩溃 病毒攻击,电涌 不 ...

最新文章

  1. C++:从子类访问父类的私有函数
  2. 第三篇——第二部分——第四文 配置SQL Server镜像——非域环境
  3. excelutil java_JAVA实现Excel的读取--ExcelUtil工具类
  4. PHPer面试指南-前言
  5. dubbo-admin构建报错
  6. 春日 [宋] 王安石
  7. python环境配置(一)——Linux下将python2.6升级到2.7 安装pip 以及升级中遇到问题的解决方法
  8. 零基础、转行学习Python是否还在纠结?这里告诉你答案!
  9. java实验报告的原理_JAVA实验报告
  10. Android性能分析工具Systrace和TraceView的使用
  11. SQL基础系列(三)——分组查询
  12. Windows驱动开发第8课(驱动签名与禁用签名打开系统测试模式)
  13. Windows 10正式版官方原版ISO镜像下载
  14. UE4灰度图生成地图记录blender生成城市地形
  15. veins中实现rsu与车辆通信
  16. 我们可以从挑战者灾难中学到什么关于网络安全的知识?一切。
  17. Java异常处理的简单总结+文件操作
  18. 2022 年合肥市经开区第七届青少年信息学竞赛 小学组试题题解
  19. 网络营销中的软文营销有什么价值?对于软文营销我们应该注意哪些问题?
  20. 股票新手入门-股票基本名词概念

热门文章

  1. 【今日CS 视觉论文速览】10 Dec 2018
  2. 0224 2101循环笔记
  3. 输入语句 readline 1006 c#
  4. 七牛云与python交互的教程
  5. linux生成大文件
  6. P2216 [HAOI2007]理想的正方形
  7. TensorFlow相关
  8. Mybatis/Ibatis,数据库操作的返回值
  9. Linux shell脚本的字符串截取
  10. 01_appium自动化环境的搭建