RHEL重置管理员密码

RHEL7

  1. 进入内核编辑界面

启动系统出现引导界面时,按下“e”进入内核编辑界面。

Hcd Hat Enterpri.sc Linux (3, 10), (1 1 7 , '3 use the and keys to Change the selection Press to edit the selected item, or for d prompt

insmod xfs set root-' hdO,msdosI' if = xy then --no-r loppy ——sct=root — t—ef i QSdOSI ——hint=' hd€, QSdOSI' 50ded72@-3s ccd-443c-ade1-41d71db1ßbdd else search — -no—f I oppu Idb19bdd ——fs-uuid ——set;root Linux16 x86 _64 ro crashkernel -auto rd. Ivm. Iv=rhel/root rd. Ivm. Iv=rhel/suap rhgb quiet .UTF-8 initrd16 Press Ctrl—x to start, Ctrl—c for a command prompt or Escape to discard edits and return to the menu. Pressing Tab lists possible

  1. 进入单用户模式

移动光标至“linux16”行,在该行末尾添加“rd.break”,然后按下“ctrl-x”来启动修改过的内核程序,进入单用户模式

  1. 修改root密码

在单用户模式,输入以下命令

#以读写权限重新挂载“/sysroot”目录

mount -o remount,rw /sysroot

#改变当前根目录至“/sysroot”目录

chroot /sysroot

#修改当前用户的密码

passwd

#在下次系统启动时让selinux对系统中的文件重新打标签使root密码的修改生效

touch /.autorelabel

#退出至上一个层级的shell

exit

#重启系统

reboot

Detected CPU fami 6 mdel 14B stepping I — this has not undergone testin Red Hat might certif ied. Please consult com for certified hard'.hre. I. 146874] •ERROR" Failed to send host log mssa 1 J i to send host rating ' . txt" Entering energencg rode. Exit the shell to continue. "jcntrnalctl" to view system logs. You might unnt to saw "'run."initranfs/rdsosreport.txt" to a USB stick or 'boot them and attach it to a bug report . suitch_root : n munt -o ,'susroot chroot 'sysrM't Chang i ng for New passt.nrd: Retype passunrd: all authentication tokens updated successful —4 _ touch sh-4.Z1t exit sui t ch_root : reboot_

RHEL8

  1. 进入内核编辑界面

启动系统出现引导页面时,按下“e”进入内核编辑界面。

Rcd Hat Enterprise Linux 64) (Uotpa) Hed Hat Enterprise Linux B .e• use the t and kegs to change the select ion. Press 'e' to edit the selected item, or 'c' for• a command prompt.

load_video set gfx_pay load -keep Linux ( inuz—4. 18 €—80. el 8 . x86 _64 kernel-auto rd. Ivm. rd. Ivm. ap rhgb qu iet initrd ($root)," ini tramfs—4 .18 .0-80.e18.xB6_64 . i mg $tuned_initrd Press Ctrl—x to start, Ctrl—c for a connand prompt or Escape to discard cd its and to the menu. pressing Tab i Sts possible completions

  1. 进入单用户模式

移动光标至“linux”行,在该行末尾添加“rd.break”,然后按下“ctrl-x”来启动修改过的内核程序,进入单用户模式

load video set gfx_pag load-keep insmod gzio I inux ($root )/vml inuz—4 root=/dev/mapper/rhel-root ro crash\ •p rhgb quiet rd. break initrd ($root)'initramfs-4 .18.0-80.e18.x86_64. img $tuned_initrd Press Ctrl—x to start, Ctrl—c for a command prompt or Escape to discard edits and return to the menu. Pressing Tab lists possible completions.

  1. 修改root密码

在单用户模式,输入以下命令

#以读写权限重新挂载“/sysroot”目录

mount -o remount,rw /sysroot

#改变当前根目录至“/sysroot”目录

chroot /sysroot

#修改当前用户的密码

passwd

#在下次系统启动时让selinux对系统中的文件重新打标签使root密码的修改生效

touch /.autorelabel

#退出至上一个层级的shell

exit

#重启系统

reboot

Detected CPU familu 6 rode' 14B stepping 1 Intel Processor - this hardunre has not undergone testin b" Hat and might not cert if consult COM for certified 1.119493] -ERROR. Failed to send log 1.119858] Failed to send log "'run/ initranfs/rdsosreport. txt" Entering mde. Exit the shell to continue. lupe "journalctl" to vieu system logs. You might unnt to saw "'run/initrarfs/rdsosrcport.txt" to a USB stick or 'boot them and attach it to a bug suitch_root munt -o 'sysroot suitch_root : A chroot 'susroot Chang i for passujr•d: neu passsor•d passtA: all authentication tokens updated successfully. touch / .autorelabcl exit suitch_root reboot

 


已发布

分类

,

来自

标签: