Linux reset forgotten root password

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:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 49 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
49 comments… add one
  • shekhar Dec 14, 2006 @ 5:03

    thanks for useful trick because many time it happens that you forget password

  • kishor Aug 11, 2007 @ 11:46

    i want password releated information

  • sajid Nov 15, 2007 @ 3:49

    how to reset root password

    • sapan yadav May 30, 2013 @ 11:43

      please write sudo bash and enter in shell as root and type passwd after that u can change

  • kekelka Dec 25, 2007 @ 15:12

    thxu very much for help

  • Pin Mar 13, 2008 @ 3:25

    Very helpful indeed. Manage to reset now.

  • Sergey Aug 10, 2008 @ 14:33

    It’s useful not only to change pass, but also to change permissions, edit configs, etc.

  • S. Nilesh Aug 10, 2008 @ 16:36

    what is the “sync” required for ? btw, I don’t think we have to do mounting if instead of S we append 1 to the end of kernel line… 1 is INIT single user mode.

  • Angel Genchev Mar 18, 2009 @ 7:51

    sync is used to synchronize Disk with OS buffers, e.t. to write any dirty buffers to the disk.

  • manoj Jun 13, 2009 @ 5:06

    How can i change the root password of another computer from this computer on network

  • Phuc Aug 22, 2009 @ 8:02

    Great help, thanks

  • George Aug 29, 2009 @ 14:57

    I am using Fedora 11 I don’t get the screen with the kernel version come up and I can’t push e to boot to single user mode. What now?

    • georges Nov 16, 2011 @ 10:14

      you’ll need a live cd for that, and the process will be more complex.
      try posting a thread in

  • Maniraj Patri Oct 16, 2009 @ 9:56

    Will it work for fedora also. Anyway thanks.

  • Syed Mohammed Jan 13, 2010 @ 15:32

    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

    • georges Nov 16, 2011 @ 10:16

      did you try what nixcraft suggested, and what was the result?

  • midhu Feb 16, 2010 @ 16:58

    thanku so much

  • Suryakant Feb 17, 2010 @ 4:19

    How to reset password if we forget password in linux?

  • Ramgopal Feb 25, 2010 @ 17:44

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

  • Prabhu May 13, 2010 @ 13:34

    Thanks for sharing the useful tips

    Vipro Computer Services

  • AJANRAMAN Jun 10, 2010 @ 6:01

    thank you very much……

  • win Aug 25, 2010 @ 6:40

    can’t to reset after booting still view “give root password for maintenance or control d” do you have other solution?

  • mangesh Oct 8, 2010 @ 8:08

    now i am working with linux an i forget the linux server root password so i want solution on that so please help me about that

  • eman Oct 26, 2010 @ 14:58

    thanx it worked

  • Richard Dec 6, 2010 @ 10:17

    Note that :
    1. Linux is case-sensitive.
    2. “single” is a keyword.

    So, you actually need to add ” s” or ” single”.
    (lower case, and you need a space before it)

  • AVIRAL Jan 25, 2011 @ 8:36

    i want to know that if i forget the password of linux. so ho could it possible to work in linux

  • Anon Jun 20, 2011 @ 2:37

    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.

  • brijesh Jul 3, 2011 @ 10:54

    Thanks Its working

  • govindaraji Jul 16, 2011 @ 7:17

    my linux user name & password forget password

  • Macdonald Rukwata Aug 12, 2011 @ 8:02

    thank you so much i managed to change the password

  • Sunag Sep 12, 2011 @ 14:43

    i have the latest natty newhal 11.01 ubuntu that just starts off no grub no loading… but i have stuck up with the root password trying to install the JRE platform…

  • mazhar Oct 29, 2011 @ 7:28

    Thank Q.
    its help me a lot.

  • Sreekanth Nov 14, 2011 @ 3:51

    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

  • 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


    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
    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
    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?

  • Pavlos Jan 21, 2014 @ 16:40

    My boot loader i GRUB

  • Pavlos Jan 21, 2014 @ 16:49

    After the 6th step it starts automatically and it failed

  • Ravichandran Kingmaker Mar 7, 2014 @ 0:54

    Which is the kernal line?

  • Jean-Vitki Jun 19, 2014 @ 15:27

    In my Os the kernel line do not appear
    I use elementary OS Luna

  • Suresh S Aug 12, 2014 @ 11:00

    very use full contents

  • MM Oct 26, 2014 @ 9:46

    Hi, how i can reset my root password with putty???

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum