What is sudo?

Raghuram Krishnaswami
3 min readDec 10, 2015

--

sudo is a command that people use a lot, without knowing its intricacies. But sudo is not to be trifled with - It can destroy your system in a multitude of ways.

For example, “sudo rm -rf /*” tells your system to delete all files. And it will obediently do it.

The only way to avoid such blunders is by avoiding ignorance.

This is an example of sudo being abused

Superuser

In computers, the Superuser is a special user who has permissions to do everything. Install new software, delete and modify system files, binding to network ports below 1024 are some examples.

This is what you would call as administrator in windows. In Linux, its usually called as root.

In Linux shell, its possible to get superuser access, by preceding your command with sudo. The system will ask for your user password, and will then run the command as superuser.

Some users, like the guest user, are not allowed to do this. Thus, only people with access to sudo can use it. The list of people who have access to sudo is specified in a file called sudoers list.

If a user who is not in sudoer’s list tries to use sudo, he will see the warning “This incident will be reported”. This is used by Randall Munroe in another xkcd comic.

Why superuser?

Why do we need this superuser, if we can get its access with just a password? All that we are achieving is making our work more tedious, isn’t it?

Well.. no.

Firstly, it makes sure that our typing mistakes do not accidentally destroy the system. As superuser, one might accidentally delete some system files, and destroy the Linux Operating System.

Secondly, there are thousands of people who just use facebook, youtube and twitter. They don’t know about the intricacies of Linux, and don’t care about it either. sudo provides a neat little abstraction of Linux knowledge this way.

If you’re still not satisfied as to why we need sudo, please check out what Principle of Least Privilege

Difference between “su” and “sudo su”

su is the Linux command to substitute(change) user.
In Ubuntu, we cannot change to root using su, as root account is locked. This means that there is no password set up for the root account, and so you cannot become root by using su.

No password is not the same as Empty Password.

However, you can change to root using sudo su

And you can change back using sudo su <username>

Note: There are other ways to change to root as well. Most notable ones are sudo -i and sudo -s. But for all practical purposes, they work exactly the same way as sudo su.

Originally published at raghuramkrishnaswami.wordpress.com on December 10, 2015.
Updated on 15th October 2017.

--

--