Skip to content

Instantly share code, notes, and snippets.

@tangoabcdelta
Last active February 8, 2021 09:09
Show Gist options
  • Save tangoabcdelta/ee450933939f854a75e18d670cb638be to your computer and use it in GitHub Desktop.
Save tangoabcdelta/ee450933939f854a75e18d670cb638be to your computer and use it in GitHub Desktop.
How to Reset Forgotten Password in Linux

How to Reset Forgotten Password in Linux

  • While your computer is booting, press F8 key (in case boot menu doesn't appear)
  • From the boot menu select the "recovery mode" option and boot into recovery mode.
  • Select the option 'Drop to root shell prompt'
  • Type the following command to change the password: passwd username
    • Example:
      • passwd bigfatsoftware
      • passwd tangoabcdelta

If you get an 'Authentication token manipulations error'

It means that the Filesystem state is in 'Read only'. To fix it:

  • Type the following command:
    • mount -rw -o remount
    • Enter this command before entering the first command
  • If the computer refuses to accept commands after selecting the 'Drop to root shell prompt' option, then do the following:
    • Mount the filesystem as read-write (rw)
    • Go to the recovery menu
    • Select "fsck"
    • This will mount your filesystem as rw
    • It will also check the disk for errors
    • After that you can use the root shell

Concerns about data loss:

  • There is no data to be lost.
  • You are just modifying the file /etc/passwd by the aforementioned steps

Prevent your computer from recovery in the future:

  • Go to terminal
  • Type sudo nano /etc/default/grub
  • Find #GRUB_DISABLE_RECOVERY="true"
  • Uncomment that line
  • Save and Exit the nano text editor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment