How to reset the administrator password in Ubuntu Linux
Read - 11 мин.
The article has been read - 468 раз
Updated - 05.10.2026
Published - 05.10.2026

How to reset the administrator password in Ubuntu Linux

Important: these actions require physical or console access to the server. For a VDS, this can be the VNC console provided by our hosting service.

What exactly are we going to recover?

Before you begin, it is important to understand the difference between an administrator user and the root account.

In modern Ubuntu installations, the root account is usually not used for regular logins. Administrative operations are performed as a regular user via the sudo mechanism.

For example, a server may have a user:

admin

who is allowed to run commands as root:

sudo systemctl restart nginx

In this case, if the password is forgotten, you need to change the password of the admin user, not necessarily the root password.

If you really need to set a password for the root account, you can do so with the command:

sudo passwd root

However, having a root password does not mean that remote root login via SSH will automatically be allowed. SSH settings may prohibit this method of connection.

When might you need to reset an Ubuntu password?

A password reset may be required in several typical situations:

  • you forgot an Ubuntu user's password;
  • you lost the VDS administrator password;
  • you cannot run commands via sudo;
  • the former system administrator no longer has access to the server;
  • you need to regain access to a physical Ubuntu Server;
  • the password was changed, but the new password is unknown.

If you still have access to another user with administrator privileges, recovery is much easier — the password can be changed directly from the running system.

Method 1. Resetting the password via another administrative account

This is the simplest and safest option if the server already has another user with sudo privileges.

First, connect to the server as an existing administrator. For example:

ssh admin@SERVER-IP

Then run:

sudo passwd USERNAME

For example, if you need to change the password of the user ubuntu:

sudo passwd ubuntu

The system will ask you to enter the new password twice.

After the password is successfully changed, you will see a message similar to this:

passwd: password updated successfully

After that, the user will be able to log in with the new password.

Method 2. Resetting the password via Recovery Mode

If you forgot the password of the only administrative user, one of the standard recovery methods is Recovery Mode.

Ubuntu provides a recovery mode from which you can get a root shell and run the passwd command.

Step 1. Reboot the server

Reboot the server in the usual way, if possible. For a VDS, this can be done through the control panel or VNC console.

During boot, you need to open the GRUB menu. Depending on the system configuration, you may need to hold the Shift key or press Esc.

Important: on a VDS or remote server, make sure you can actually see the boot console. If GRUB is not accessible via SSH, use VNC/IPMI or the virtual machine management console.

Step 2. Open Advanced options for Ubuntu

In the GRUB menu, select:

Advanced options for Ubuntu

A list of installed Linux kernels will appear.

Select the required kernel version marked with:

(recovery mode)

For example:

Ubuntu, with Linux 6.x.x-x-generic (recovery mode)

Press Enter.

Step 3. Open a root shell

After Recovery Mode boots, the recovery menu will appear. Select the option:

root - Drop to root shell prompt

You will then get a command prompt with root superuser privileges.

Warning: a root shell gives you full control over the system. Running commands incorrectly can damage the operating system or lead to data loss. Run only the necessary commands.

Step 4. Remount the file system as writable

In Recovery Mode, the root file system may be mounted as read-only (read-only).

In that case, the passwd command will not be able to change the password.

Run:

mount -o remount,rw /

After the command completes, the file system should be writable.

Step 5. Determine the username

If you do not remember the username exactly, you can look at the user directories:

ls /home

For example, the result may look like this:

admin
ubuntu
user

Suppose the required user is named:

ubuntu

Step 6. Change the user's password

Now run the command:

passwd ubuntu

Instead of ubuntu, specify the name of the required user.

The system will ask you to enter a new password:

New password:

Then you will need to enter the password again:

Retype new password:

If everything went well, you will see the message:

passwd: password updated successfully
Done: the user's password has been changed.

Step 7. Reboot the server

After changing the password, you need to exit Recovery Mode and boot Ubuntu in normal mode.

You can run:

reboot

If the command does not work because of Recovery Mode specifics, you can use the corresponding reboot item in the menu.

After booting, try to log in with the new password.

How to verify the new password via SSH?

If the SSH server is configured to use password authentication, try to connect:

ssh ubuntu@203.0.113.10

Enter the new password.

If login succeeds, check administrator privileges:

sudo -v

If necessary, you can check whether the user belongs to the sudo group:

groups ubuntu

The result should include the sudo group if that is what is used to grant administrator privileges.

What to do if the password is changed but SSH does not let you in?

This is an important point. Successfully changing the Ubuntu password does not mean that SSH necessarily allows password login.

The server may be configured for authentication exclusively by SSH key.

In that case, the command:

passwd ubuntu

will indeed change the user's password, but the connection:

ssh ubuntu@SERVER-IP

may still fail with an error.

In this situation, you need to check the SSH configuration:

/etc/ssh/sshd_config

In particular, pay attention to the parameter:

PasswordAuthentication

If password authentication is disabled, having a new password will not let you log in via SSH with a password.

VDS tip: if the server uses SSH keys, do not disable or delete the working access key just to test the new password. First make sure the new authentication method actually works.

How to reset the root password in Ubuntu?

If the task is specifically to set or change the password of the root account, use the following from a running system with administrator privileges:

sudo passwd root

After running the command, set the new root password.

You can check whether a root password is set directly from an administrative session, but the mere presence of a password does not mean remote SSH login as root is allowed.

For example, SSH may contain the restriction:

PermitRootLogin no

In that case, root login via SSH is prohibited regardless of the password that is set.

Alternative method — changing GRUB parameters

In some cases, Recovery Mode may be unavailable or may not work correctly. Then you can use emergency boot via GRUB by changing the Linux boot parameters.

This method requires especially careful handling, because it gives you a root shell even before the system starts normally.

In the GRUB menu, select the required Ubuntu entry and press:

e

Find the line that begins something like this:

linux /boot/vmlinuz...

You can add the following to the end of the line:

init=/bin/bash

Then boot the system with the modified parameters. Depending on the GRUB version, booting is usually done with the Ctrl+X key combination or the corresponding hint at the bottom of the screen.

After getting the root shell, the file system must be remounted as writable:

mount -o remount,rw /

Then you can change the password:

passwd username

When the recovery is complete, reboot.

Important: GRUB parameters are intended for system recovery and should not be used as a permanent boot configuration. After recovery, boot the system with the normal parameters.

What to do if disk encryption is used?

If the Ubuntu system disk is protected with encryption, for example LUKS, the passwd command alone is not enough to gain access to the file system.

First, you need to successfully unlock the encrypted volume. Without the encryption key or passphrase, resetting the system password will not give you access to the encrypted data.

For servers with critically important data, you should check in advance where the recovery key is stored and how the disk is unlocked after a reboot.

What to do if it is a VDS server?

If SSH is unavailable because of a forgotten password, you need an alternative access channel:

  • VNC console;
  • Rescue Mode;
  • Live ISO or a recovery system.

After gaining console access, you can use Recovery Mode or another suitable recovery method.

Why you should not simply reinstall Ubuntu?

Reinstalling the operating system is an extreme measure that is usually not needed just because of a forgotten password.

When reinstalling, you may lose:

  • user files;
  • server application configurations;
  • databases;
  • web server settings;
  • SSL certificates;
  • Docker configuration;
  • network settings;
  • application data.

If the problem is only a forgotten password, you should first use the standard access recovery tools.

What password should you set after recovery?

The new administrator password should be unique and sufficiently complex. It is not recommended to use:

  • the company name;
  • the server name;
  • a phone number;
  • simple combinations such as 123456;
  • passwords that are already used on other services.

For servers, it is recommended to use a long unique password and, where possible, switch to SSH keys instead of permanent password authentication.

What to check after regaining access?

After a successful login, it is recommended to check the server's state.

Check the current user

whoami

Check the user's groups

groups

Check that sudo works

sudo -v

Check the Ubuntu version

cat /etc/os-release

Check SSH

sudo systemctl status ssh

If the server is used to host a website, application, or database, after regaining access it is also recommended to check the state of the main services.

Quick guide

If you need to quickly recover the password of an Ubuntu administrative user via Recovery Mode, the sequence is as follows:

  1. Reboot the server.
  2. Open the GRUB menu.
  3. Select Advanced options for Ubuntu.
  4. Select Recovery Mode.
  5. Open the root shell.
  6. Remount the file system as writable.
  7. Determine the username.
  8. Run passwd username.
  9. Set the new password.
  10. Reboot the server.
  11. Verify login via SSH or console.

Main commands

For convenience, here are the main commands in one place:

# Remount the root file system as writable
mount -o remount,rw /

# List users
ls /home

# Change a user's password
passwd username

# Change the root password
passwd root

# Reboot the server
reboot

Conclusion

Resetting a forgotten administrator password in Ubuntu Linux usually does not require reinstalling the operating system. If you have another administrative user, the password can be changed directly with the sudo passwd username command.

If access to the administrative account is completely lost, the most convenient option for Ubuntu Server is to boot into Recovery Mode, get a root shell, remount the file system as writable, and run the passwd command.

For a VDS, it is especially important to have a backup access channel in advance — for example, a VNC console. This allows you to regain control of the server even if SSH is unavailable.

After regaining access, it is recommended not to limit yourself to simply replacing the password. Check the SSH settings, administrator privileges, the SSH keys in use, and the overall security of the server.

Useful: if the server is accessible from the Internet, it is recommended to use SSH keys, disable unnecessary authentication methods, restrict SSH access via a firewall, and regularly install Ubuntu security updates.

Answers to popular questions

How soon can I start using the service?

The user account is opened immediately upon application.

You can start using the service immediately after payment.

Author of the article:

user

Editor-in-Chief

Danaev Almaz