Listen to this story



Disable Linux root account and increase security

Andy Vilchez
4 min read

The vast majority of people consider that Linux is a "safe" operating system with which you will not need to use antivirus or other programs.

However, the truth is that although Linux is an operating system less prone to viruses and other malware, it is not infallible. There are also ways in which a cybercriminal can affect the system.

That is why, below, we will talk about how to solve one of the biggest security gaps in your Linux operating system, the root user.

Disable Linux root account and increase security – Technology – WebMediums
Avoid hacks by increasing security on your Linux computer.

Linux has a root account that is enabled by default and is something that can represent a fairly significant security risk.

A standard Linux user has limited control over the operating system. In short, you only have basic access to the system, you can install applications and use the system normally. However, you will not be able to make changes that require higher privileges.

In the operating system there is an account that has "root" access. This means that this account is capable of modifying system files that, if not handled carefully, can end up rendering it unusable.

The root user gives access to each part of the system and executes privileged commands. This can be dangerous for two things, the first is that people without knowledge damage the system. And the second is that malicious people end up having access to that account and can steal your information, since it has unlimited access.

Why disable the root account in Linux?

As we already mentioned, the Linux root account is enabled by default. If you use your computer for traditional use, it is unlikely that you will run into problems. It is always advisable to disable this account to avoid some kind of problem.

If the password of your user with root access is known to someone or ends up being exposed, the person who uses it can make changes to your computer's system. And this can represent several problems, from the theft of personal data and information to leaving the computer unusable.

Steps required to disable root account in Linux

Disable Linux root account and increase security – Technology – WebMediums
Disable the root account in Linux in a simple way.

Next, we will talk about the necessary steps to be able to disable the root account in a simple way. If you follow all the steps to the letter you will be able to.


Generally, Linux accounts allow you to use the command "sudo" or "su" which allows you to run commands as root.

It may happen that you cannot use the "sudo" command on your system, this will depend on the distribution you have installed. In this case, you will need to install the "sudo" command, but you will have to use the "su" command and install the packages from the terminal.

Having verified this, the next step is to disable the account with root privileges.

Locking the root account

Disable Linux root account and increase security – Technology – WebMediums
SU root command on Linux.

Fortunately, disabling the root account is something really simple, this will prevent anyone on the computer from being able to use it. Once disabled, when you need to make a change to the system that requires elevated permissions, you will need to resort to the "sudo" command and a password.

To disable the root account in Linux you will only need to access a terminal and type the following command:

sudo passwd -l root

That's it, once you have done this the account will be disabled and no one (including you) will be able to use the "su" command on your computer. This means that every time you want to perform an action with privileges on the computer you have to enter the password, which makes your system a little more secure.

Does this prevent someone from hacking into my computer?

Disable Linux root account and increase security – Technology – WebMediums
Locking the root account is an additional layer of protection for your computer.

Maybe you think that after this you will no longer have to worry about the security of your system. It is important that you are clear that this does not make it invulnerable, it only makes it much more difficult to hack your computer.

In short, this works as an extra layer of protection that will help make it more difficult for someone to access your computer.