Cart

    Sorry, we could not find any results for your search querry.

    Resetting your root password in Ubuntu and Debian

    It may happen that you forget your root password over time, but fortunately, there is a solution for this. In this article, we'll show you how to reset your root password in Ubuntu and Debian. 

    There are two options for resetting your root password: via Linux rescue mode and via the Grub menu. The Linux rescue mode is slightly easier to start than the Grub menu (as it appears only briefly on the screen and is easy to miss). However, you are free to choose either, and both will lead to the same result. 

    If you still have your root password but have lost the password for another user, use the following command as a root user to change the password:

    passwd username
     

     

    Resetting Your Root Password via Linux Rescue Mode

     

    Step 1

    To reset your root password, switch to the 'Linux rescue mode' of your VPS. In the TransIP control panel, go to the VPS for which you want to reset the password, and click the pop-out button at the bottom left of the console.

     


     

    Step 2

    Select 'Options' > 'Boot Linux rescue mode'.

     


     

    Step 3

    After starting Linux rescue mode, you’ll see a menu where you can choose the SystemRescue option you want to use. Do not change anything, and press ‘Enter’ to proceed (or wait for the timer to expire).

     


     

    Step 4

    You will now enter the rescue menu, which you can recognize by:

    sysrecue login: root (automatic login)
    [root@sysrecue ~]#

    To reset your password, you need to mount the root, dev, proc, and sys filesystems. Normally, your root partition will be found in /dev/vda1, but check to be sure with the command:

    lsblk

    You’ll see an overview like the one below, where in this example, vda1 (or /dev/vda1) is the name of the root partition.

    NAME                MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
        loop0                 7:0    0 689.3M  1 loop /run/archiso/sfs/airootfs
        mtdblock0            31:0    0   753M  0 disk /run/archiso/bootmnt
        vda                 254:0    0   150G  0 disk
        ├─vda1              254:1    0   150G  0 part

     

    Step 5

    Now mount the root, dev, proc, and sys filesystems:

    mount /dev/vda1 /mnt
    mount --bind /dev /mnt/dev
    mount --bind /proc /mnt/proc
    mount --bind /sys /mnt/sys 

     

    Step 6 

    Chroot to the mounted file system:

    chroot /mnt

    Chroot stands for ‘change root’ and allows you to change the root directory for the current process and its child processes.


     

    Step 7

    Change your root password and update both the filesystem labels and initramfs to apply the changes:

    passwd
    
    update-initramfs -u

     

    Step 8

    Exit the chroot environment and unmount the various filesystems:

    exit
    umount /mnt/dev
    umount /mnt/proc
    umount /mnt/sys
    umount /mnt

     

    Step 9

    Finally, restart your VPS with the command ‘reboot’. That's it! You can now use your new root password.

    reboot 

    If you see the (re)installation screen for your VPS, close the pop-up window of the VPS console and click ‘reset’ at the bottom of the VPS console in the TransIP control panel to give your VPS a hard reset. You will then be directed to the regular login screen.


     

    Resetting Your Root Password via Grub

     

     

    Step 1

    To reset your root password using this option, first go to the Grub menu of your VPS.

    Restart your VPS and quickly press the 'ESC' key repeatedly to interrupt the boot process (the Grub menu appears only briefly).

    Note: Use the VPS console in the TransIP control panel and click the ctrl-alt-del button instead of the ‘reset’ or ‘reboot’ button. This keeps the following screen visible for longer. 

    You’ll see a screen like the one below:

    ubuntu grub menu


     

    Step 2

    Press the ‘e’ key on your keyboard to edit the boot parameters (see the last part of the screenshot above). By default, the kernel boots in ro-mode (read-only):

    ubuntu grub parameters read only

    In Debian, it will say 'ro quiet'. Change 'ro' / 'ro quiet' to 'rw init=/bin/bash' (without quotes). The text may not fit on one line, so you’ll see a \ added at the end to indicate it continues on the next line.

    The result will look like this:

    ubuntu grub parameters read write

    Now press  ctrl + x to boot your VPS with the modified boot parameters.


     

    Step 3

    After booting, you will enter the bash prompt. You can now reset your root password with the command:

    passwd root

     

    Step 4

    Finally, reboot your VPS with the command below. The -f (force) option is often necessary to execute the reboot.

    reboot -f

     

    Your root password has now been reset! This brings us to the end of this guide on resetting your root password in Ubuntu and Debian.

     

    Need help?

    Receive personal support from our supporters

    Contact us