当前位置: 首页 > news >正文

How to recover a root password in Red Hat-based Linux systems

We’ve all inherited systems we didn’t have any part of building. If you are a systems administrator, the day will come when you need to work on a system and don’t have the root password for any number of reasons—and statistically speaking, that day will come at the worst possible moment: you need access to that box *right now*.

Recovering the root password might seem frightening, but it doesn’t have to be difficult or complicated. On a RHEL/CentOS version 7 or later system, thanks to the Grub bootloader it’s actually pretty simple.

  1. Begin by starting a kettle of water to boil (Optional, but recommended).
  2. First, you need console access: Either at a keyboard and monitor locally, or via Virtual Machine remote console, you will need to see and interact with the bootloader.
  3. Reboot the machine: As soon as the bootloader comes up with the selection screen, quickly tap the up and down arrows up and down to pause the countdown.
  4. Select the kernel you want to boot into, and hit 'e': This will take you into a screen where you can edit the grub bootloader script.
  5. Find the line that refers to the kernel: There will be a series of 'boot parameters' here: these are instructions passed during the loading of the kernel.
    1. For RHEL/CentOS 7, the line starts with 'linux16'.
    2. For RHEL/Centos 8x, and Fedora the line starts with 'linux'.
  6. Add 'rd.break' at the end of that line (There are other things you can do here, but for now, this is all you need)[ Note: This change is temporary ].
  7. Now hitCtrl-xto run the edited bootloader script.
  8. You’ll boot to a 'rescue' prompt that looks like this:switch_root:/#.
  9. Remount the root partition in read-write mode so that you can run commands. Enter the following:mount -o remount,rw /sysrootand then hit ENTER.
  10. Now typechroot /sysrootand hit enter. This will change you into thesysroot (/)directory, and make that your path for executing commands.
  11. Now you can simply change the password for root using thepasswdcommand.
  12. Next, before you reboot, you will need to make sure that SELinux allows the file changes. At the prompt ,enter:touch /.autorelabel. This will signal SELinux on the next reboot that the filesystem has changed (the changed password) and allow the change to be loaded. This will cause the whole filesystem to be 'relabeled' which might take a while, depending on the size of the filesystem and the speed of the machine, so be aware of this possibility.
  13. Typeexitto leave the chroot environment and enterreboot.
  14. Go and make a cup of tea to reward yourself for your cleverness: The water should be boiling now. (Again, optional but recommended and highly dependent on your participation with Step #1.)

And that’s it. You should now have root password access to this system.

Want to try out Red Hat Enterprise Linux?Download it nowfor free.

http://www.jsqmd.com/news/405477/

相关文章:

  • 【Python3教程】Python3高级篇之Markdown模块
  • vp 2025春季PAT甲级
  • 2026年国内有实力的投影机品牌排行榜,4K投影机/雾幕投影机/山体投影机出租/激光投影机出租,投影机工厂电话 - 品牌推荐师
  • 一天一个Python库:pyjwt - 安全地编码和解码JWT
  • 2026澳门租车市场分析:跨境服务,哪家租车更靠谱?商务车租赁/包车/商务租车/班车租赁/中巴租赁,租车公司推荐排行榜 - 品牌推荐师
  • 2026防火涂料性能全知道:工程选型有妙招,厚型钢结构防火涂料/超薄型钢结构防火涂料,防火涂料实力厂家口碑排行榜 - 品牌推荐师
  • python中的装饰器(1)
  • python基于flask的高校机房设备管理系统vue
  • python基于flask的社区居家日常报修维修平台vue
  • python基于flask的医疗药店连锁药店管理系统vue
  • python基于flask的幼儿园托幼机构管理系统文件vue
  • python基于flask的汽车4s店销售预约试驾vue
  • 探索经典平面手性:基于COMSOL的光学仿真之旅
  • 靠昆虫复眼思路做感知,多小镜头拼接视野,颠覆单镜头,输出全景感知。
  • [LangGrpah] Tool calls demo
  • 凸优化数学基础笔记(八):一维线性搜索法(一)
  • 工业园区的AGV调度是个头疼的问题——既要赶在客户方便的时间送货,又要控制物流成本。最近用MATLAB折腾了个遗传算法方案,实测效果不错,给大家看看实现思路
  • [AI提效-25]-与AI大模型交互:一场接纳人类社会多样性的修行
  • python基于flask的创梦宝大学生创业众筹捐赠平台vue
  • python基于flask的工程公司企业门户网站vue
  • python基于flask的交通违章处理系统的设计与实现vue
  • 99元/年!腾讯云部署OpenClaw,手把手教你打造7×24小时AI私人助手-插件扩展篇
  • 奥特曼:人类吃 20 年饭不如训练 AI,全网炸了,
  • 看完就会:10个降AIGC平台测评,继续教育降AI率全攻略
  • AI提示词管理工具AiShort
  • 主题测试 - -于勤
  • 2.23
  • 基于深度学习电梯扶梯危险行为检测系统的设计与实现
  • Atcoder ARC215 解题报告
  • AI元人文:空性、科学与舞台——基于“自感注册”的存在论拓展