Getting started with Linux can be a bit confusing. There are tons of new features and terms that you have probably never heard of before. Two such terms are Root and Sudo.
What are Sudo and Root? These two terms are some of the most important ones you expect to find when talking about the most popular Linux distributions. Of course, understanding what they are and how they are used is of the utmost importance.
Whether you’re a first-time Linux newbie or a returning user looking to brush up on your knowledge, we’re committed to helping you get back on track. We’ll explain exactly what each one is, how they are used and why they are important.
What is Sudo and Root on Linux? Why are they important?
Each of these two terms is primarily important for accessing specific permissions. More precisely the same permissions. They differ from each other in how to get this access.
First, we’ll start with Root, what it is and why it matters.
What is Root?
The root directory, often referred to as the “superuser”, is a special directory represented by a forward slash (/). Root has access to all files and commands on any Unix-like operating system.
– /
Not to be confused with the root user’s home directory, which is represented as / root, Root (/) is the starting point for the entire directory, which is hierarchically structured like a tree, and all other directories branch out. from.
Access to root authority
Those who have the necessary permissions to access Root have special privileges that allow them to modify the system at will. These privileges also provide the ability to grant certain access rights to other users. The foolish and reckless use of such power can lead to disaster for the system. You could be dealing with a complete and complete system failure, or at least a damaged system.
This illustrates the importance of a system like Root. It’s pretty much a system. Too much interference can lead to adverse results, so Root should only be used to enable other superuser privileges for specific accounts.
By using the visudo command to edit / etc / sudoers, you can grant least privileges to other types of accounts, such as supervisor, where they can add new users and change their accounts without having to enter Root itself.
From now on, these accounts will no longer need Root access and instead can use the sudo command to perform user management tasks. Other tasks will still require superuser permissions, which only the root user can grant. If you ever need to grant additional permissions, you can repeat the steps above, grant them, and then use the logout command to return to your current account immediately.
Avoid using Root to modify anything at the account level. The root should be reserved for system changes only. Apart from the root user, access to other accounts must not be allowed. Add permissions based on the needs of other users and groups, so they can access what they need with the sudo command.
What is Sudo?
Sudo, which stands for DO superuser, is one of the most important commands in the Linux system administrator’s arsenal. It allows you to perform certain tasks without the need to log in as root or use the Su (switch user) command.
Importance of Sudo
The Sudo command can help you bypass the annoying “Access Denied” prompt you might encounter when trying to run something in a command terminal. Add the sudo prefix to any Linux command and it will run the specified command with elevated privileges that are required to perform certain administrative tasks.
You can compare sudo to the less friendly version of the Windows User Account Control dialog box that pops up whenever you try to do something important. You know, the one that asks if you want to continue with what you are doing requires you to press YES or OK, and then moves on to the request. Sudo is similar to this, but in practice it is a little more dramatic.
Without proper permissions in Linux, things can quickly become inconvenient. Important files that you thought you saved may not have been saved correctly. The original code you are trying to compile does not work. The recently installed program may no longer start. In other cases, you may simply get an Access Denied mark preventing you from moving on. You can avoid all of this by first asking for permission, using sudo as a prefix to your commands.
Something as simple as rebooting your system will require superuser privileges. If you enter reboot mode without sudo, you will receive an “Access Denied” message. Instead, to bypass the annoying prompt, type
sudo restart
You should receive a completely different invitation. The one that tells you that your system will reboot.
After using sudo, you may be asked to enter your account password. Make sure you enter your account password and not the root user account password. If the password is correct, the command should be sent.
Why Sudo is a better alternative to the root (/)
Using sudo is much safer on your system than logging into root and trying to execute commands. You run a greater risk of messing up while you’re in root mode, so it’s easy to run elevated commands without risk.
Sudo is also a better alternative to the user switch command (Su). Su will ask for the root password and provide a superuser prompt in the form #. This # means you are in the root directory. At this point, you can execute all elevated commands. The problem occurs when you forget that you are still in the root directory and start running commands that might change your system. Even a simple mistake in the team itself due to a typo can lead to terrible results.
Do yourself a favor and use sudo. Typos, a cat jumping into your lap, and even God’s wrath are less of a threat to your system. Sudo is also the preferred way of working on the Ubuntu distribution. So, if you are using this command, you should be familiar with this command.
Sudoers
We have touched on this topic before, but never discussed what exactly. Sudoers is a file that controls which accounts have access to the sudo command. By default, you can find the file in / etc / sudoers. You can safely edit this file using the visudo command, vi is an elevated editor.
Visudo will allow you to edit the sudoers file and save your changes. It will also lock the file, preventing anyone from making changes to it. After you finish editing the file, errors will be analyzed before saving from the file.
The sudoers file contains many different options where you can specify which users from which groups can run certain commands. To give a user the sudo command capabilities, enter the username, followed by a space and the word ALL in capital letters.
username ALL
You can do the same for groups by adding% in front of the group name and then ALL in capital letters.
% groupname ALL
The users and groups you have given sudo permissions to will now have full root privileges.
–
Comment on “HDG Explains : What Is Sudo & Root On Linux?”