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

linux单用户修改root密码(linux更改用户密码方法)

  • linux
  • 2024-03-15 21:01:52
  • 3239
Linux 单用户模式下修改 root 密码
要素:

1. 重启系统并进入单用户模式:在 GRUB 引导菜单中,选择 "Single-User Mode" 选项。


2. 挂载根文件系统:运行命令 mount -o remount,rw / 将根文件系统挂载为可读写。


3. 启动 shell:运行命令 chroot / 进入根文件系统。


4. 修改 root 密码:运行命令 passwd 更改 root 密码。


5. 退出单用户模式:运行命令 exit 退出 chroot,然后运行命令 reboot 重新启动系统。


示例:
# 重启系统并进入单用户模式
Reboot system and enter single-user mode
# 挂载根文件系统
Mount the root file system
$ mount -o remount,rw /
# 启动 shell
Launch shell
$ chroot /
# 修改 root 密码
Change the root password
$ passwd
# 退出单用户模式
Exit single-user mode
$ exit
$ reboot