Linux reset forgotten root password

Q. I forgot my root password, how can I get into my system?

Advertisement

A. You can reset forgotten root password under Linux by booting system into single user mode or emergency mode (also known as rescue mode).

My boot loader is GRUB (see LILO boot loader below)

)Following is the procedure to reset root password if you are using GRUB as a boot loader:

  1. Select the kernel
  2. Press the e key to edit the entry
  3. Select second line (the line starting with the word kernel)
  4. Press the e key to edit kernel entry so that you can append single user mode
  5. Append the letter S (or word Single) to the end of the (kernel) line
  6. Press ENTER key
  7. Now press the b key to boot the Linux kernel into single user mode
  8. At prompt type passwd command to reset password:

You need to mount at least / and other partitions:
# mount -t proc proc /proc
# mount -o remount,rw /

Change the root password, enter:
# passwd
Finally reboot system:
# sync
# reboot

My boot loader is LILO

At LILO boot loader type linux single and press [ENTER] key:
Boot: linux single
When you get the # prompt you will need to type passwd root to reset password:
# passwd
Reboot system:
# sync
# reboot

See also:

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

49 comments… add one
  • Eswaramoorthi.D Dec 8, 2011 @ 5:04

    Thank you

  • virus Dec 27, 2011 @ 8:19

    HOW TO CHANGE USERNAME ????????????????????

  • samish Jul 24, 2012 @ 11:11

    what if my root folder in fedora is comming with red cross sign i cannot open it

  • Array Aug 8, 2012 @ 16:36

    i need to access our server hosted somewhere but the password is being forgotten….so how do i access the server from remotely….anyone help pls

  • Usman Mar 14, 2013 @ 7:55

    Hi,

    upon mounting the /proc mount point, i am getting error to specify the file system too. what should i enter there?

  • Danish Zahur Mar 29, 2013 @ 4:41

    Working great… Thank you

  • Timothy Jun 4, 2013 @ 19:18

    Am a new linux user.I lost my password for linux mint os how can i rest it and create a new user.Also i keep on reset ing my desktop and time setting every time i power on.The system has no memory of previouse logins

  • Vdst Jul 8, 2013 @ 19:08

    Awesome, thanks for that bit of info!

  • Calin Vlad Dec 25, 2013 @ 22:41

    I encounter the same problem and I solved quite easy I might say
    first I wirte
    user@pc:~$ sudo bash
    [sudo] password for user: (you type your sudo password)
    then it automatically switch to
    root@pc:/home/user#
    here you write
    root@pc:/home/user# passwd
    and the output is
    Enter new UNIX password: (here you write your new password)
    then you hit ENTER
    and
    Retype new UNIX password: (retype your new password)
    and if everything goes perfect
    you should have this output:
    passwd: password updated successfully

  • Pavlos Jan 21, 2014 @ 16:38

    My linux system writes

    An error occured during the file system check
    dropping you to a shell? The system will reboot when you leave
    the shell
    Give a root password for maintenance or type control d to continue.

    I don not remember the root password
    what can i do?

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.