The root user has full administrative privileges in the Ubuntu operating system. As root, you can manage users, network settings, packages, services, and all system files.
By default, the root account in Ubuntu is usually locked, and the sudo command is used to perform administrative actions. However, in some cases, administrators need to set or change the root password to perform special tasks.
These instructions are suitable for:
Connect to the server via SSH as a user with sudo privileges:
ssh username@server-ip
Example:
ssh admin@192.168.1.10
If the root account doesn't already have a password, run:
sudo passwd root
The system will prompt you for a new password:
New password:
Retype new password:
After successful execution, a message will appear:
passwd: password updated successfully
After this, the root user will be able to use the set password to log in locally.
To change an existing root password, you can also use the command:
sudo passwd root
Enter the new password twice to confirm the change.
After successful modification, the system will display:
passwd: password updated successfully
After setting the password, you can switch to the root user:
su -
Enter the root password:
Password:
After successful authorization, the command prompt will change:
root@server:~#
In most cases, setting a separate root password is not required. To run administrative commands, we recommend using:
sudo command
For example:
sudo apt update
sudo apt upgrade
To open a full root session:
sudo -i
or
sudo su -
This method is considered more secure and is recommended by Ubuntu developers.
If you no longer need to use root, you can disable the password:
sudo passwd -l root
After this, logging in as root using the password will no longer be possible.
To reactivate:
sudo passwd root
You can check the account status with the command:
sudo passwd -S root
Example output:
root P 2026-06-19 0 99999 7 -1
Where:
Since Root has complete control over the system, so the password must be as secure as possible.
Recommended:
Example:
Airnet#Root2026!Secure
Not recommended:
123456
root
password
admin123
This error is usually related to a lack of administrator rights or problems with the file system.
Check for sudo privileges:
sudo -l
This error occurs when attempting to change the root password without administrative privileges.
Use:
sudo passwd root
For internet-accessible servers, we recommend:
You can change the root password in Ubuntu with one command:
sudo passwd root
However, for most servers, we recommend using sudo and don't enable persistent root login unless necessary.
Properly setting access rights can improve server security and reduce the risk of unauthorized access.
All current versions of Ubuntu are available on AIRNET servers:
Choose the right plan and get full root access to your server:
The user account is opened immediately upon application.
You can start using the service immediately after payment.