找回密码

CentOS 系列

  1. GRUB 菜单按 e 键进入编辑模式(openEuler 24.03 GRUB 账号密码为 root openEuler#12)
  2. 找到 linux 开头那一行,在这一行的最末尾,空格后添加 rw init=/bin/bash
  3. 改完参数,按 Ctrl+X 直接启动,会进入 root 无密码 shell。
  4. 重置 root 密码 passwd root
  5. touch /.autorelabel(如果SELinux是启用的,需要添加这个文件)
  6. exit
  7. reboot

Ubuntu 系列

  1. 重启计算机:启动时,按住 Shift 键(有时是 Esc 键),进入 GRUB 菜单。
  2. 选择恢复模式:在 GRUB 菜单中,选择带有 (Recovery Mode) 字样的内核版本。
  3. 进入Root Shell:在恢复模式菜单中,选择 root - Drop to root shell prompt
  4. 挂载根文件系统(一般可不用执行):执行以下命令将根文件系统以读写模式挂载:
    mount -o remount,rw /
  5. 重置密码:使用 passwd 命令重置所需用户的密码。例如,要重置 username 的密码:
    passwd username
    然后按照提示输入新的密码。
  6. 重启系统:重置密码后,输入以下命令重启系统:
    reboot