In this lesson, you'll learn how to work with sudo.
Why do we need sudo? It's all about using administrative privileges on
Linux. By default, you always have a user with the name root.
This user is really unrestricted. Permissions don't apply for the user
root, and for that reason you should avoid working as root.
Sudo allows authorized users to run tasks with escalated privileges.
And to use it, you use sudo followed by the command that you want to use, like sudo LS root.
Not everybody can use sudo to allow sudo usage. Users must be
a member of the sudo group, and different sudo groups exist.
On Red Hat, the name of that group is wheel, and on Ubuntu, the name of that group is sudo.
Sudo configurations can be created to allow users to perform specific tasks only.
That's something we won't cover here, but let me show you how to use sudo as an administrative user.
Okay, so I'm going to start this demo by typing who am I?
Who am I? Showing your current username and my current username is student.
I'm also typing the ID command because the ID command is showing a list of groups that the
user is a member of, and that reveals that user student is a member of the group wheel.
And that's all that I needed to know.
So let's do a quick test. Let me use LS l root.
This is trying to show a long listing of else in the directory root.
The directory root happens to be the user root home directory.
And as an ordinary user, you don't get access to that directory.
But if I'm repeating my previous command and I'm putting
sudo in front of the command, look at what's happening.
It is prompting for the password for user student. I'm entering my password and there we can see all
the files. Well, it's just one, but still all the files in the home directory of user root.
So when you put sudo in front of a command, then you run it with super user privileges.
But the important thing to realize is that this only works if you are authorized to use sudo.