how to use root on debian

Debian: How To Enable The Root User (Login & SSH)

If you click our links and make a purchase, we may earn an affiliate commission. Learn more

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” access.

On Debian, 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.

Master Linux Commands

Want to level up your Linux skills? Here is the perfect solution to become efficient on Linux.

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 Debian?

The “root” user still exists on Debian 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 Debian?

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’s no real need to keep it enabled.

Always Forgetting Linux Commands?
Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.

Download now

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:

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 update
It won’t work with your main user, administrator privileges are required.

Prefer reading without ads and popups?
Members get an ad-free version of every guide, plus exclusive project support.
Join the Community | Sign In

But if, instead, you use:
sudo apt update
It 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.

You can basically do everything with sudo, so, in theory, there is no need to use “root” anymore.

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> sudo
Running this command from an authorized user, obviously.
More details here: How to Fix: “sudo command not found” on Linux (2 reasons)

Always Forgetting Linux Commands?
Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.

Download now

Quick note: If you find it hard to remember all these commands, I’ve put them all on a one-page cheat sheet. You can download it for free here so you have it handy whenever you're working on a project.

What is the Root Password on Debian?

The root user is disabled by default, and so doesn’t have any password set. On older Debian releases, 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:

Use the exit command to get back to your normal privileges.
exit

Always Forgetting Linux Commands?
Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.

Download now

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).

Related: How to Log in as Another User in Linux Terminal (3 Ways)

Enable Root Login on Debian

Before using the “root” account directly on Debian, 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:

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.


🛠 This tutorial doesn't work anymore? Report the issue here, so that I can update it!

Prefer videos over reading? The RaspberryTips Community members get exclusive video lessons every month. Join now and watch them all right away. Get instant access.

Enable Root Login over SSH

In addition to having the root user disabled by default on Debian, connecting to it via SSH once enabled is also blocked.

Always Forgetting Linux Commands?
Grab This Cheat Sheet!
I've compiled the must-know commands in a simple PDF for quick reference.

Download now

You can use “ip a” to find the Debian IP address from a terminal.
If you need help with this, here’s how to quickly find the current IP address In Linux / Ubuntu.
Or if you prefer an easier way with your phone, install the RaspberryTips Android App, and it will automatically find your Raspberry Pi’s IP address for you!

Here is how to allow logging in as root via SSH:

  • Make sure the SSH server is installed:
    sudo apt install ssh
    You 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 root access over SSH as soon as possible.

You can revert the SSH configuration to block access 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.

Similar Posts