麒麟Kylin服务器版-通过单用户重置root密码

一、单用户模式修改root密码

  1. 重启服务器系统后,将光标移动到第二项,按【e】键进入用户登录页面。

image

  1. 此时会进入让你输入用户名和密码的界面,这个界面是有麒麟默认的用户和密码,用户是root密码是Kylin123123,具体会出现下面这种形式:
Enter username:
 
root
 
Enter password:
 
Kylin123123      //输入密码时不显示
  1. 在linux开头所在行的结尾加上"rd.break console=tty0",按【Ctrl +X】进入单用户模式。代码如下:

如果是ro那么要改成rw

    insmod xfs
 
    set root='hd0,msdos1'
 
    if [ x$feature_platform_search_hint = xy ]; then
 
        search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hin\
 
t-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1'  5fa324b9-b\
 
c33-48b6-9852-bb42182eb115
 
    else
 
        search --no-floppy --fs-uuid --set=root 5fa324b9-bc33-40b6-9852-bb42\
 
182eb115
 
    fi
 
    linux   /vmlinuz-0-rescue-214eea67aabb447a9938ad74f1c07f43 root=/\
 
dev/mapper/klas-root ro resume=/dev/mapper/klas-swap rd.lvm.lv=klas/root rd.lv\
 
m.lv=klas/swap rhgb quiet crashkernel=1024M,high audit=0 rd.break console=tty0
 
    initrd  /initramfs-0-rescue-214eea67aabb447a9938ad74f1c07f43.img
 
 
    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. 进入到单用户模式后,先按【回车】键继续操作,在该模式下依次输入以下命令,代码如下:
 
Generating"/runinitramfs/rdsosreport.txt"
 
 
 
Entering emergency mode. Exit the shell to continue.
 
Type "journalcti" to view systeml ogs.
 
You might want to save "/run/initramfs/rdsosreport.txt" to a USB stick or /boot
 
after mounting them and attach it to a bug report.
 
 
到了这里,你会看到下面信息,此时需要按回车键,然后就会出现sh-5.0#
Press Enter for maintenance
 
(or press Control-D to continue):
 
sh-5.0# mount –o remount,rw /sysroot   \\重新挂载/sysroot为可读写模式
 
sh-5.0# chroot /sysroot    \\进入/sysroot子系统重置
 
sh-5.0# export LANG=en_US.UTF-8    \\设置系统编码为UTF-8
 
sh-5.0# passwd root    \\更新root用户密码
 
Changing password for user root.
 
New password:Jan16@123  \\设置root用户密码,输入时密码不显示
 
Retype new password:Jan16@123  \\重新输入root用户密码,输入时密码不显示
 
passwd: all authentication tokens updated successfully.
 
sh-5.0# touch /.autorelabel    \\更新selinux上下文
 
sh-5.0# exit  \\输入exit两次退出重启
 
exit
 
sh-5.0# reboot
posted @ 2025-03-27 15:31  皇帽讲绿帽带法技巧  阅读(1480)  评论(0)    收藏  举报