foo

foo

foo

Reset Password in Linux

Reset root password#

CentOS 4, 5, 6#

Press 'e' after rhgb quit, add 1 or single
Press Enter to save, press 'b' to boot and modify password with passwd

CentOS 7#

Method 1#

Enter grub2 and press 'e' to edit. Scroll down to the linux16 line and delete rhgb, quiet, and LANG parameters. To easily move to the end of the line, press ctrl+e. To move to the beginning of the line, press ctrl+a. The linux16 line will be linuxefi on UEFI systems.

#linux16 /vmlinuz-3.10.0-327.el7.x86_64 root=/dev/mapper/centos-root \ ro rd.lvm.lv=centos/root rd .lvm.lv=centos/swap rd.break
linux16 /vmlinuz-3.10.0-327.el7.x86_64 root=/dev/mapper/centos-root \ rw init=/sysroot/bin/sh rd.lvm.lv=centos/root rd .lvm.lv=centos/swap rd.break
Press ctrl+x to enter single user mode

#mount -o remount,rw  /sysroot
chroot /sysroot
# restorecon /etc/shadow
passwd root
# Update system information
touch /.autorelabel
exit
reboot

Method 2#

rw init=/bin/bash
linux16 /vmlinuz-3.10.0-327.el7.x86_64 root=/dev/mapper/centos-root \
 ro rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rw init=/bin/bash
Press ctrl+x
/usr/sbin/load_policy -i
mount -o remount,rw /
passwd root
exec /sbin/init 3

# Method 3-gpt
Reset root password on CentOS 7:

1. Restart your CentOS 7 server and select the Kernel from the GRUB menu.
2. Press 'e' to edit the Kernel option.
3. Find the line starting with "linux16" and change "ro" at the end to "rw init=/sysroot/bin/sh".
4. Press "Ctrl + X" to start the CentOS 7 system.
5. When in single user mode, run the following commands:
chroot /sysroot
passwd root
  1. Enter a new root password and confirm.
  2. Run the following command to apply the changes:
touch /.autorelabel
  1. Reboot CentOS 7:
exit
reboot

Reset root password on Ubuntu:

  1. Restart your Ubuntu system and select the Kernel from the GRUB menu.
  2. Press 'e' to edit the Kernel option.
  3. Find the line starting with "linux" and change "ro quiet splash $vt_handoff" at the end to "rw init=/bin/bash".
  4. Press "Ctrl + X" to start the Ubuntu system.
  5. Ubuntu will automatically start bash as the root user. Enter the following command:
passwd root
  1. Enter a new root password and confirm.
  2. Reboot Ubuntu:
reboot

Reset root password on Debian:

  1. Restart your Debian system and select the Kernel from the GRUB menu.
  2. Press 'e' to edit the Kernel option.
  3. Find the line starting with "linux" and change "ro quiet" at the end to "rw init=/bin/bash".
  4. Press "Ctrl + X" to start the Debian system.
  5. Debian will automatically start bash as the root user. Enter the following command:
passwd root
  1. Enter a new root password and confirm.
  2. Reboot Debian:
reboot
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.