CentOS Stream 10
Sponsored Link

root パスワードをリセットする2024/12/20

 

root パスワードを忘れてしまった場合は以下のようにしてリセット可能です。
(GRUB ブートローダーにパスワードがセットされていない場合に有効な手段)

[1] システムを再起動し、GRUB2 のメニュー画面が表示されたら [e] キーを押下します。
その後は以下のように進めることで root パスワードを再設定することができます。
 # [e] キーを押下する
 +----------------------------------------------------------------------------+
 |*CentOS Stream (6.12.0-35.el10.x86_64) 10 (Coughlan)                        |
 | CentOS Stream (6.12.0-32.el10.x86_64) 10 (Coughlan)                        |
 | CentOS Stream (0-rescue-13e0d866d1054d54a96f6690117098a8) 10 (Coughlan)    |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 +----------------------------------------------------------------------------+

      Use the ^ and v keys to select which entry is highlighted.
      Press enter to boot the selected OS, `e' to edit the commands
      before booting or `c' for a command-line.

 # 以下のように [linux] 行の行末に [rw init=/bin/bash] と追記する
 +----------------------------------------------------------------------------+
 |load_video                                                                  |
 |set gfxpayload=keep                                                         |
 |insmod gzio                                                                 |
 |linux ($root)/vmlinuz-6.12.0-35.el10.x86_64 root=/dev/mapper/cs-root ro res\|
 |ume=UUID=5fa38690-3750-415e-99a3-155a720bc1bf rd.lvm.lv=cs/root rd.lvm.lv=c\|
 |s/swap console=ttyS0,115200n8 crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M \|
 |rw init=/bin/bash                                                           |
 |initrd ($root)/initramfs-6.12.0-35.el10.x86_64.img $tuned_initrd            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 |                                                                            |
 +----------------------------------------------------------------------------+

      Minimum Emacs-like screen editing is supported. TAB lists
      completions. Press Ctrl-x or F10 to boot, Ctrl-c or F2 for
      a command-line or ESC to discard edits and return to the GRUB menu.

 # 以上のように入力後、[Ctrl-x] キーを押下する

.....
.....

[  OK  ] Stopped dracut-cmdline.service - dracut cmdline hook.
         Starting initrd-udevadm-cleanup-db.service - Cleanup udev Database...
[  OK  ] Stopped systemd-tmpfiles-setup-dev…Create Static Device Nodes in /dev.
[  OK  ] Stopped systemd-sysusers.service - Create System Users.
[  OK  ] Stopped systemd-tmpfiles-setup-dev…ic Device Nodes in /dev gracefully.
[  OK  ] Stopped kmod-static-nodes.service …Create List of Static Device Nodes.

# プロンプト表示後、以下のように対応
bash-5.2#

# SELinux 有効の場合は、次回起動時 SELinux リラべリングを実行するよう設定

bash-5.2#
touch /.autorelabel
# パスワード設定

bash-5.2#
passwd

Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
# 再起動して完了

bash-5.2#
exec /sbin/init
関連コンテンツ