Recuperar la contraseña root

Si olvidaste la contraseña (password) del root, no te preocupes es posible restablecerla.  este método es valido para la mayoría de sistemas operativos linux, tales como centos, debian, ubuntu, opensuse, etc…


Sigues los pasos siguientes:

Reinicia el sistema y cuando aparezca el menú de arranque GRUB2, pulsa la tecla «e«.

# push "e" key
      CentOS Linux (3.10.0-327.4.4.el7.x86_64) 7 (Core) with debugging
      CentOS Linux (3.10.0-327.4.4.el7.x86_64) 7 (Core)
      CentOS Linux (3.10.0-327.3.1.el7.x86_64) 7 (Core) with debugging
      CentOS Linux (3.10.0-327.3.1.el7.x86_64) 7 (Core)
      CentOS Linux 7 (Core), with Linux 3.10.0-229.el7.x86_64
      CentOS Linux 7 (Core), with Linux 0-rescue-ffa496be96ad482cb94373394cec7

      Use the ^ and v keys to change the selection.
      Press 'e' to edit the selected item, or 'c' for a command prompt.

setparams 'CentOS Linux (3.10.0-327.4.4.el7.x86_64) 7 (Core)' 'fedora'

        set gfxpayload=keep
        insmod gzio
        insmod part_msdos
        insmod xfs
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1'  c4df086e-3699-4e02-b7cf-b47e614f6920
          search --no-floppy --fs-uuid --set=root c4df086e-3699-4e02-b7cf-b47e614f6920
        # add "rw init=/bin/bash" to the end of line
        # remove "rhgb", "quiet", "LANG=***" all if there are in this line
        linux16 /vmlinuz-3.10.0-327.4.4.el7.x86_64 root=/dev/mapper/centos-root \
            ro console=ttyS0,115200n8 
            systemd.debug rw init=/bin/bash
        initrd16 /initramfs-3.10.0-327.4.4.el7.x86_64.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.

      # after inputting above, push "Ctrl-x" key to proceed

[  OK  ] Stopped udev Coldplug all Devices.
         Stopping udev Coldplug all Devices...
[  OK  ] Started Plymouth switch root service.
[    6.814528] systemd-journald[95]: Received SIGTERM from PID 1 (systemd).

# after initramfs switch_root prompt is displayed, do like follows
# set SELinux relabeling on next boot if you enabling SELinux
bash-4.2# touch /.autorelabel
# set password
bash-4.2# passwd 
Changing password for user root.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
# restart System and complete to reset
bash-4.2# exec /sbin/init


Como ves, es un proceso rápido y sencillo.


Agregar comentario

1 logo sololinux

Suscríbete a SoloLinux

Recibe todos los nuevos artículos es tu correo electrónico

You have Successfully Subscribed!

Ir al contenido