Greetings, and welcome to a new series on Veronica Explains I'd like to call "Lil Linux Lessons".
I'm Veronica, and today I'm going to talk about sudo,
an essential access control program on most modern systems.
Linux is a multi-user system, and in most Linuxes,
the "root" account is the one with ultimate authority over the system.
While you may have one, several, or dozens of users in your Linux system,
it is the root account that has the maximum authority to make changes...
...we sometimes call that authority "privilege",
and the root user has the maximum amount of privilege on the system.
Unprivileged end users cannot delete or modify certain critical system files,
thus keeping your system running smoothly.
Sounds simple enough, but it gets a bit complicated in practice.
You open up the potential for accidental damage.
For example, you might start a process that isn't supposed to
have root privileges, and that process inadvertently takes down the system.
This has security implications, and is just plain messy.
Plus, if you're in a multi-user environment, such as a work server,
you won't necessarily know *who* was doing *what* as the root user.
This has implications for auditing when something goes wrong.
So, we need a better system, and that's where `sudo` comes in.
Sudo, or "soo doo" as some people call it, is a command that means
"superuser do" or "substitute user, do", depending on who you ask.
In the default system settings,
it elevates your non-root user to have "root privileges" when needed.
This way, system administrators don't have to share a root password between different users.
This makes auditing easier, and in general, makes administration much easier to handle.
Now, some Linux users don't like using sudo- they like switching to root when needed with "su",
and then switching back when done.
If you know what you're doing with a root account,
and keeping the security tight, that can work. But in my experience as a system administrator
and Linux user, I think sudo is a cleaner option for most folks.
In the terminal, sudo goes just before the command you'd like to complete as root.
For example, if I want to edit /etc/hosts, which is traditionally only writable by the root user,
I can use `sudo vim /etc/hosts`.
The command to edit a file in vim is `vim [filename]`, and placing
`sudo` in front of it means it should execute this command with elevated privileges.
I have sudo permissions in this system, and you likely will too if it's your
home system and you're the only user- we'll talk more about that in a minute.
The first thing it does right away is prompts me for a password.
That's useful as an additional check that the person logged in is the actual user.
It'll cache that password for a brief time, so you won't have to enter it repeatedly
over and over and over again.
After I enter the password and press "enter",
the command is executed, with the elevated privileges needed to edit the file.
Now, under most distro's default permissions set,
sudo users can basically do anything root can. But you might want to segment it a bit,
especially in a multi-user environment, like you might find in a business.
Luckily, you can edit the sudoers file to accomplish this,
allowing some users elevated privileges, but less than complete root access.
That's an advanced topic, that I might save for a future video.
If you don't have sudo access to the machine,
you might need to ask the system administrator to add you to the sudo group for your distro.
Typing `groups` will tell you what groups you're part of. On many distros,
the "sudo" group will be called "sudo" or "wheel". Your distro's documentation will tell you more.
Here on Pop!_OS, the easiest way to add a user to the sudo group is with `sudo usermod -aG sudo`,
and then their username.
This command elevates us to root permissions,
then appends the existing group list by adding one more group for the user: "sudo".
Sudo is a powerful tool that's functional on nearly every production Linux and Unix system today.
And feeling comfortable with how it works is a critical part to getting comfortable on Linux.
What additional commands would you like to see a 'lil lesson on?
Make sure to leave a comment and let me know.
And as always, don't be afraid to ask questions, occasionally break things,
and get comfortable at messing around with Linux.
Because Linux is awesome, and so are you.
[Child shouting] "1, 2, 3, 4!"
[punk music]