Linux reset forgotten root password

Posted on in Categories , , , , last updated September 19, 2007

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

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:

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

Share this on (or read 49 comments/add one below):

49 comment

  1. Dear sir,

    We are using server with linux o/s but the login and password has been misplaced so could you kindly help us geting our server started.

    Your kind favour will be highly appreciated.

    Thanks and kind regards.

    Syed Mohammed

  2. Hi vivek,
    Normally in solaris, to reset the password.
    boot cdrom -s
    mount the root disk
    edit the /etc/shadow
    null the value
    save and sync
    umount
    reboot.
    How to reset the root password in solaris, when the disks are under Veritas.
    when it is mirrored under Veritas VM, how do I do? ( consider 2 disks c1t0d0 and c1t1d0). thanks for your time.
    -Regards
    Ram

  3. You can likely just change root’s password using the normal way if you have sudo permissions: “sudo passwd root”. Setting root’s password initially is likely needed anyway under certain cases, such as when you need to ssh/sftp in as root during emergencies.

  4. For RHEL-6 do the following in single user mode.

    By default SELinux enabled in RHEL-6 and it will not allow you to change the password.
    Run the below commands to change the password for root.
    #setenforce 0 (check the SELinux changed to Permissive using command “getenforce”)
    then go for password reset
    #passwd

  5. 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

  6. I encounter the same problem and I solved quite easy I might say
    first I wirte
    [email protected]:~$ sudo bash
    [sudo] password for user: (you type your sudo password)
    then it automatically switch to
    [email protected]:/home/user#
    here you write
    [email protected]:/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

  7. 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 Comment