How to Disable the Root Account in Linux

Many Linux users are aware of or have heard the phrase “root” before. Essentially “root” is a user that has complete and total control of the entire Linux system, and there’s literally nothing it can’t change. This makes root dangerous and something that only advanced users who understand the implications of root should be using.

For the most part, users don’t have access to the root user. On some mainstream Linux distributions (mainly Ubuntu), there isn’t even a possibility for a user to set up the root password. In fact, they don’t even tell you the password. Linux users are able to bypass this practice by using the sudo command. This command temporarily elevates the user permission so they can run system management tasks without being a root user.

So, with all this in mind, why would we use “root” if sudo is there? The reason is that sudo doesn’t work at the time. Some system commands will only work with the root user. And overall, entering sudo every single time can get tiring, and users often just log in with the root user to get everything done.

Why would you delete the root password?

Deleting the root user is a security precaution and overall just something that is good to do. It is still possible for users to go around “root,” and this can add a needed piece of security to your system. For example, a Linux computer with a complicated username password and a weak root password is vulnerable to possible security problems or intruders.


However, having a root user with no password has its advantages. No root password means nobody will be able to log in, thus hackers will never be able to completely mess up a system. Furthermore, users can still get a root shell with sudo by doing sudo -s or sudo su.

Removing the password

Deleting the root password is very simple. To start, open a terminal window and gain root access. Do this with sudo -s. This will give the user root access without logging into the root user. Then, remove the root password with this command:


This will completely disable the root login. No user has access to it from this point on.


Alternatively, it is possible to delete the current password so no user knows what it is:

To re-enable root, do:


The system asks for a new password, and the root account will be re-enabled on the system with the new password.


When it comes to Linux, or Unix-like operating systems in general, the root user is the most powerful tool. With it the entire system can be modified and tinkered with. This is great for enthusiasts and those who like to take Linux installation and tweak everything. Still, problems can arise. Root can become dangerous when it falls into the wrong hands. Bad things can happen. As a result, only those who truly understand the importance of the root user should use it.

Image credit: 365 x18 My Laptop On ZenWalk Linux

Derrik Diener Derrik Diener

Derrik Diener is a freelance technology blogger.


  1. The thing about disabled root access may give some people a false sense of security.

    These days, malware, hackers, intrusion and compromised systems are a sad reality. Linux systems are perceived by some to be “more secure” than most other systems. To some degree there’s an element of truth: Linux systems have not been a great target, same with OS X, BSD, and UNIX systems, but no network connected system is ever 100% secure, even if it is relatively secure.

    The purpose of this note is to let the uninformed know that shutting down root won’t keep out a determined hacker. They will simply look for the weak point in the security of the system.

    Good password choices and multiple factors of authentication can help, and keeping the system current with the latest security updates will also help.

    Carefully monitor any systems that you are concerned about regarding sensitive information.

  2. Sorry, just had a finger check. The below should be with the above comment.

    Dirk, I don’t think you are giving Linux users enough credit. After all, they DID show some smarts by switching from Windows to Linux. Your article makes them sound like a bunch of clueless, airhead Windows users. Most of Linux users do not need, or want, to be protected from themselves by taking away their root access. Unix/Linux, unlike Windows, was designed to be configurable. For those that are afraid of their own shadow there are Ubuntu and its derivatives where the developers took most of the choices away from the users.

  3. A few comments…

    Even if you lock the root account , an attacker can compromise your system just as easily as a simple user do. With sudo you can do almost anything on the system as a super user is doing . So if someone gets your user passwd then he can launch many kind of attacks. Of course he cannot do serious staff but he can DO significant DAMAGE to your system. Now if you change sudo’s privileges then you will end up in locking yourself out of the system and not be able to do a simple update or change a driver module or…!!!
    Security is something very important and it needs a lot of reading and experience.

    There is a saying :” a good hacker exists because there is a bad administrator” .

Comments are closed.