What is “root” in Linux?

The root user is the most powerful entity in the Linux universe with limitless powers, for better or for worse. Create user? I have it. Destroy a file system? Oops, got that too.

The origin story

The root user is the Linux superuser. You can literally do anything. Nothing is restricted or prohibited for root . Whether you are a superhero or a supervillain depends on the human user who takes on the role of system administrator. Errors by the root user can be catastrophic, so the root account should only be used for administrative purposes.

The concept of the root user was inherited from Unix, which had a root user as the administrative superuser. But it is not known exactly where the name “root” comes from. Some people think it’s from the Multics operating system which is older than Unix.

Ken Thompson and Dennis Ritchie , two of the most important architects and authors of Unix, had both previously worked on the Multics. Multics had a filesystem that began at a point called the root directory or “/”, and all other directories and subdirectories branched out from the root like an inverted tree. It’s the same kind of tree structure that was adopted from Unix. Perhaps Unix also took over the root user from Multics?

Browse the Technical documentation from Multics reveals a variety of references to logical root volumes, physical root volumes, root cards, and the root directory. However, there is no mention of a root user account or a user named “root”.

Another theory suggests that in the early days of Unix, the superuser ‘s home folder was the “/” root directory of the filesystem. The superuser needed a name. The term “root user” was used in place of an official name, but the term stayed and became the official name.

That seems more likely, but no one seems to be able to say for sure where the root user got their name from.

the sudo command

On any operating system, it is advisable to reserve the superuser for administrative purposes only and to use a normal user account for the rest of the time. In fact, most modern Linux distributions won’t let you log in as the root user.

Of course this is Linux so you can configure it to allow the root user to log in. But the less time you spend signing up than root , the better. Apart from protecting yourself from the catastrophe caused by typing errors if you can’t log in as a root , no one else can do that. Anyone who gains unauthorized access to your system cannot log in as root to limit the damage they can do.

But if you log in as root disabled, how do you manage your linux computer? Well that’s what the sudo Command is for. It doesn’t require the root user to log in. It granted temporarily root ‘s forces on you. It’s like picking up Thor’s hammer Mjolnir and temporarily receiving Thor’s powers. But you can only pick up the hammer if you are worthy. Likewise, not everyone can do that sudo Command. the sudo Command only confers root ‘s powers upon you when found worthy and added to the sudoers list.

There is another command similar to sudo called su . With sudo , authenticate yourself with your own password. With su , authenticate yourself with the password of the root user. This is important in two ways. First, it means that you need to assign a password to the root user in order to use it su . By default, the root user does not have a password, which adds to the security. if root has no password, you cannot log in as root .

Second, if you set a root password, anyone with that su Command must know the password. And password sharing is a security no-go, and even more so for the root password. Anyone who knows the root password can tell someone else. If you need to change the root password, you will need to communicate the new password to anyone who needs to know.

It is much safer to use the sudoers list to restrict who can use it sudo , and let each privileged person use their individual passwords for authentication.

Using sudo

The / etc / shadow file contains the username of each account on your Linux computer along with other information, including each account’s encrypted password, when the password was last changed, and when the password expires. Since it contains sensitive information, it can only be read by root .

When we try to use that wc Command to read the lines, words and characters in the shadow file, we are denied permission.

                      wc /etc/shadow

If we are in the sudoers list and use the same command with sudo at the beginning of the line we are asked for our password and the command is executed for us. If you are the only user on your Linux computer, you will be automatically added to the Sudoers list when the system is installed.

                      sudo wc /etc/shadow

Since we are running the command as root, the wc Command is executed. Nobody denies the root.

the sudo The command used to mean “superuser do”. It has been improved so that you can run a command like any user, so it has been renamed to Do Substitute User. The command is actually executed as if the other user had executed it. If you do not provide a username, sudo used by default root . If you want to use a different user, use the -u (User) option.

We can see the commands are being executed as a different user by running the whoami Command.

                      sudo whoami
                      sudo -u mary whoami

How to determine the current user account on Linux

Run as root without su. to use

The catch with sudo is that you have to use “sudo“At the beginning of every command. If you’re just typing a command or two, it’s no big deal. Having to perform a lengthy series of commands can become tiresome. It may be a chore, but it serves as a useful safety lock for root ‘s powers, and you have to consciously remove the security every time.

There is a way to effectively log in as a root that doesn’t help su and does not require the root user to have a password.

Warning: Be careful when using this method. Any command you issue will be happily executed with no questions asked – even if it’s destructive.

Using sudo to run a bash shell, a new shell opens with root as a user.

                      sudo bash

Notice that the prompt changes. The last character of the prompt is now a hash “#” instead of a dollar sign “$”.

How the prompt text is displayed varies from distribution to distribution. In Ubuntu we are informed that the user root and shows the name of the computer and the current working directory. The color of the prompt also changes.

Because we are root , we can execute commands that would normally require the use of sudo .

                      wc /etc/shadow

To exit the root user’s shell, press “Ctrl + D” or enter “exit” and press “Enter. “


Less Superman, more Clark Kent

If you’re on the sudoers list, you have super powers over your Linux system. Remember, Superman spends more time in his meek alter ego than he does in his red cloak.

Use your regular user account whenever possible. Just change in root when it is really necessary.

Related Posts