SUDO is one of the most important and recommended methods to allow any user to access the system without giving them root access.
If you are still accessing your Linux system with root access, then stop right now and create a new user with SUDO privileges.
Modifying anything in a system with root access can be dangerous. Like you left your system logged in and someone intentionally tries to create some mess in your system or installing, removing any packages. In your system, it prompts them asking with an account password to make sure you are completely aware of what you are about to do.
The short answer is no Because there is no way to secure any system if the user with SUDO privileges is already compromised by an attacker. Do not think of it as a security solution for your system.
The root term is used to define the administrator account. Where SUDO is used to define users with access to perform administrator tasks in the system. The root user has complete access to the system, run any program, add or remove any user whether they have SUDO privileges or not, etc.
Creating new user with SUDO privileges
To create a new user with SUDO privileges, make sure that there is a group with the name SUDO in your system. For that, type the following command in your Linux terminal.
$ cat /etc/group | grep sudo sudo:x:27:
Make sure the above command sometimes does not work for a normal user. If your account does not have SUDO privileges, try to run this command in the root user account and create your account from there.
Suppose the above command doesn’t output anything like mine,
sudo:x:27: in your system. Then most probably, you were on different Linux distribution than Ubuntu.
So, do not worry about that. There is still another way to achieve this. Just follow this guide properly; otherwise, you can create a mess in your system.
First, I will guide you on creating a SUDO privilege user if the sudo group exist in your system.
Type below command to create a new user: I am creating a user with the name trendoceans.
Make sure to run this command if your account has SUDO privileges like in my case I have.
If your account does not have SUDO privileges, then the only way to achieve this is to log in as a root user and then continue this guide and, at that time, remove the sudo string from the following command.
$ sudo useradd trendoceans
Once you executed the above command, a new user will be created in your system. To confirm, type the following command in your Linux terminal.
$ cat /etc/passwd | grep trendoceans trendoceans:x:1004:1007::/home/trendoceans:/bin/bash
Now time to assign the SUDO group to this account. For that, we use the
usermod command, which is used to modify a user account.
$ sudo usermod -aG sudo trendoceans
-a: This syntax use to append any group or user to another user.
-G: This syntax is used to specify that you wish to append a group to the user. In my case, my user is trendoceans, and the group I wish to append is sudo.
To verify that you successfully added your account to the SUDO group. Type the following command in your terminal.
$ groups sys network power lp wheel sudo trendoceans
As you see, sudo is also in output, which means you successfully added sudo to your group list.
If you are facing any issue then let me know in the commet section.
Innovative tech mind with 10 years of experience working as a computer programmer, web developer, and security researcher. Capable of working with a variety of technology and software solutions, and managing databases.