Linux password reset root

From PeerFreedom Wiki
Jump to navigation Jump to search

How to change root password.

Can you be root?

If you can now become root e.g.

  • you know root password
  • you have other user and he can sudo into root
  • you can ssh login as root

then just become root, and then command passwd or passwd root.

Forgot root password?

If you forgot root password and have no other method to become root:

When computer is booting, be in the GRUB menu (press up/down arrows to pause the grub menu if it boots up too fast).

Select the normal boot option, but do NOT run it. Instead edit it (key e.g. e).

In the editor of GRUB option, select (up/down arrows) the line with linux and in this line, at the end of the line (use arrows to move in this text editor) write text: linux=/bin/bash (as a separate argument, that is put spaces around it of course).

Then boot that option (information how to do it are on screen, e.g. F10 maybe).

Then you will be booted into system in a special mode. You should be normally asked to decrypt hard drive and so on as on normal boot process, but at the end you will be in a bash console as a root user.

There do passwd , you might need to first do mount -a or mount / -o remount,rw as often in such special boot mode the filesystem will be partially in read only mode.

At end execute also sync to be sure, wait frew seconds and somehow reboot machine.