How to Reset Your Root Password in Debian and Ubuntu

Introduction

This article will teach you how to reset a forgotten root password from the GRUB menu. The instructions should work on the following operating systems:

  • Debian 10
  • Debian 11
  • Ubuntu 18.04
  • Ubuntu 20.04
  • Ubuntu 22.04 LTS-server

Instructions


First, login to GleSYS Cloud and navigate to the virtual machine in question.

The next step is to reboot the server. You can do that by clicking Reboot in the dropdown menu called Actions or by opening a Console from the same place and pressing Ctrl-Alt-Del in the console view.

Picture below: When rebooting, the GRUB menu will appear, and to edit the boot parameters of the server, press key 'e.' If you are running Ubuntu 18.04, you need to press and hold Shift when rebooting for the GRUB menu to appear.


reset-root-password-ubuntu-debian--grub-menu


Picture below: This is your current boot parameters. Step down to the second last text line starting with 'linux' and delete ro and everything that comes after (quiet in our case, but others could, for example, also have no_timer_check there).


reset-root-password-ubuntu-debian--current-boot-parameters


Picture below: You replace this with rw init=/bin/bash. Then press Ctrl-X or F10 to boot up the server.


reset-root-password-ubuntu-debian--new-boot-parameters


Now you can run the command passwd to set a new root password and then run exec /sbin/init to reboot the server one last time.

root@(none):/# passwd

Output
New password:
Retype new password:
passwd: password updated successfully

root@(none):/# exec /sbin/init

Finally, test the newly reset password once the login screen shows up!


Hittar du inte det du söker?

Kontakta oss gärna för mer information. Vi hjälper dig att komma fram till den bästa lösningen för dina behov.

Skicka e-post Ring 0200-23 88 00