Ubuntu Server: How To Enable The Root User (Login & SSH)
For a long time, root was the default user on Linux, but it’s now disabled on most distributions. If like me, you were used to it, this article will answer your questions and guide you with the new best practice. I’ll also show you some workarounds if you really need “root”.
On Ubuntu Server, using “sudo” is the recommended method to get administrator privileges with the main user, instead of using “root”. If needed, the “root” user can still be enabled by setting up their password.
Let’s start with a bit of theory, to give you the context, and then I’ll show you how to enable root if you really want it, either in a terminal or even for SSH usage.
If you need help with Linux, I’ve got something that can help you right away!
Download my free Linux commands cheat sheet – it’s a quick reference guide with all the essential commands you’ll need to get things done on your system. Click here to get it for free!
Is there a root user on Ubuntu Server?
The “root” still exists on Ubuntu Server and most Linux distributions, but can’t be used by default. The account is disabled for security reasons.
Why is the root user disabled on Ubuntu?
The root user was an easy target for hackers. It always has the same name (“root”) on any Linux distribution, and if the password was cracked, the hacker could get access to the entire system without limitations.
That’s why Debian, and most distributions based on it (like Ubuntu), decided to disable the superuser by default on new installations. Also, there are ways to get administrator privileges temporarily on these systems, so there is no real need to keep it enabled.
If you check the user list on your system, you’ll still find it, with the ID 0, but most likely can’t log in with it:
Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.
Download now

Sudo: a better way to run root commands
The sudo command is an abbreviation of “super user do”, and allows any user with enough permissions to run commands as if it was the superuser (root).
For example, if you try to update your system with:apt updateIt won’t work with your main user, administrator privileges are required.
But if, instead, you use:sudo apt updateIt should work if the current user has the permission to use sudo:

Sudo may ask for your password (the user password), to make sure it’s still you on the computer, but aside from that, it gives you the same privileges as root.
Members get an ad-free version of every guide, plus exclusive project support.
Join the Community | Sign In
You can basically do everything with sudo, so, in theory, there is no need to use “root” anymore.
Related article: How To Use ‘sudo’: The Complete Linux Command Guide
Note: Not all users can use “sudo” by default, only the first user you created when installing your system. To give permission to another user, you need to add it to the “sudo” group, with:sudo adduser <username> sudoDoing this from an authorized user, obviously.
Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.
Download now
Tip: Command lines can be a pain to memorize. I put the essential Linux commands on a printable cheat sheet so you don't have to keep googling them. You can grab the PDF here if you want to save some time.
What is the root password on Ubuntu Server?
The root user is disabled by default, and so doesn’t have any password set. On old Ubuntu versions, it might be the one set during the installation, there is no default value.
If you have access to a user account with the sudo permission, you can easily switch from the user to the root account with:sudo su
If it asks for a password, type the one from the current user (“pat” in my example), and then you’ll be logged in as root:

Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.
Download now
Use the exit command to get back to your normal privileges.exit
I have explained that using “sudo” should be sufficient in most cases and that you can even temporarily switch to the root prompt in a terminal by using “sudo su”. You shouldn’t need anything more, but let’s discuss how to enable root if you really want to do this (not recommended).
Enable root login on Ubuntu Server
Before using the “root” account directly on Ubuntu Server, a password should be set via the command:sudo passwd
It will first ask for the current user password (“pat” in my example), and then ask you to create a password for the superuser:
You might also like: Turn your Raspberry Pi into a money-making machine

As explained previously, having root enabled on your system is a major security issue, so at least try to use a strong password for it. Length is key, using a password generator like this one can help you to get something long enough but easy to remember.
After setting up the password for the root user, you should be able to sign in with it directly when the system boots. But it won’t work for remote access, like with SSH, because there is an additional security measure to avoid this.
Stuck on this project? Ask me or other Pi users in the RaspberryTips Community. We help each other out and you'll get answers quick. Join and fix it together.
Enable root login over SSH
Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.
Download now
In addition to having the root user disabled by default on the Ubuntu server, connecting to it via SSH once enabled is also blocked.

Here is how to allow logging in as root via SSH:
- Make sure the SSH server is installed:
sudo apt install sshYou probably enabled it during the system installation, but it’s not mandatory, so take a few seconds to check that. - Edit the SSH server configuration file:
sudo nano /etc/ssh/sshd_config - Find the line starting with “PermitRootLogin” in this file:

As you can see, it’s forbidden to use it by default. - Uncomment this line, and switch the configuration to:
PermitRootLogin yes
- Save and exit (CTRL+X).
- Restart the SSH service to apply the change:
sudo service ssh restart
Once done, you should be able to use the root user directly from any computer on the same network:

Reminder: while enabling access to your system with the root user might be convenient, especially during the initial configuration of your system, it’s a huge security risk to keep it enabled all the time, and there is no real need to keep it enabled. Please try to use the “sudo” commands instead, and disable it as soon as possible.
You can revert the SSH configuration to block accesses with root, or completely disable the account with:sudo passwd -l root
I also recommend reading and following my security tips for any Linux server here. I share the most important things you should do to keep your system safe. Working as a system administrator for almost 20 years, it was like my checklist for any new server installation.
Whenever you're ready, here are other ways I can help you:
Master Linux Commands: Overwhelmed with Linux commands? This book is your essential guide to mastering the terminal. It includes practical tips, real-world examples, and a bonus cheat sheet to keep by your side.
The RaspberryTips Community: Need help with Linux or want to chat with people who actually get it? Join the RaspberryTips Community and get access to private forums, exclusive lessons, and direct support.
You can also find all my recommendations for tools and hardware on this page.
