In the early days of Linux, things were exponentially more complicated. Distributions were much less mature, but they also required the use of a special system account to accomplish certain things. That account was root, and with it, unlimited power over your operating system.
Too: This Might Be the Perfect Introduction to the Official Ubuntu Spin Linux
To demonstrate the power of the root account, one trick you could always play on unsuspecting users was to ask them to replace themselves with the root user. su order And then let them issue the following:
The rm command is used to delete files and folders. With a combination of r (recursive) and f (force), you will delete everything from the root folder (/), thus rendering your system unusable.
Too: Can’t remember a Linux command you’ve run before? let history repeat itself
Thereafter, any commands requiring administrative privileges were run through the root user. To do this, you must either change to the root user (with the su command) or log in as the root user. Both of these options were ultimately considered a security problem. Why? If you logged in as the root user and walked away from your system, anyone could do anything they wanted. The same is true with changing to the root user and leaving a terminal window open.
Of course, it’s more complicated than that. Having root user access means that if a hacker gains access to your system, they can turn into the root user and wreak havoc on the machine.
Eventually, it was decided that something had to give. From that need Sudo was born. Sudo stands for “superuser do” and effectively gives a regular user (who belongs to the Administrators group) access to administrator-like powers. This solved two problems:
- The root user can be disabled (so it can’t be easily leveraged).
- Only users in the Administrators group (more on this in a bit) can run administrative tasks.
This was a significant step forward for Linux, which not only strengthened the security of the system but also made it easier for the users.
Too: best linux distribution for beginners
With sudo, users no longer need to change to the root user or log in to that account to run administrative commands (such as installing software). Users can run those administrator activities via sudo with the same effect as if they were run from the root user account. On top of that, it offers better control over who can do what on a given system. When attempting to run a command that required administrative privileges, the user only had to type in their user password (also known as their sudo password) and the command would go off without a hitch (so long as it was run properly). goes).
For example, instead of first changing the root user with su and then issuing the update/upgrade command on an Ubuntu-based distribution, you can simply issue the command:
sudo apt-get update sudo apt-get upgrade -y
By running apt-get through sudo, the user is given temporary administrator privileges and can issue those commands successfully.
What about users who are not in the Administrators group?
Regarding the basics of using sudo, any user you want to grant access to that particular power must be a member of the Administrators group for that distribution. For example, on Ubuntu-based distributions, that group is sudo, whereas, on Red Hat-based distributions, that group is called wheel.
Too: How to Permanently Mount a Drive in Linux (and Why You Should)
If you have a user who is not a member of the Administrators group, when they try to run a command with sudo, they will see something like:
olivia is not in the sudoers file. This incident will be reported.
How do you fix this? You add them to the Administrators group. So, for an Ubuntu-based distribution, the command to add a user to the Administrators group would be:
sudo usermod -aG sudo USER
where USER is the username in question.
On a Red Hat-based distribution (such as Fedora), that command would be:
sudo usermod -aG wheel USER
where USER is the username in question.
After running the command, the user must either log out and log back in, or make the system aware of the changes with the command:
Once a user has been added to the Administrators group, they can use sudo to run commands that require administrative privileges.
Too: Best Linux Laptops for Consumers and Developers
Sudo has made Linux not only more secure but also more user friendly. No longer needing to make changes to (or log in to) the root user account, avoids many serious security pitfalls and allows you to manage user access to administrator tasks.











