Sometimes it may be the case that you wish to apply the sudo instead of a root account which is readily available in your system. (Debian, Fedora…)
To use sudo instead of root (su root) do the following steps.
1. open terminal client
2. become root user by typing su root
3. write the following command as a root: visudo
Note: With visudo you can edit sudoers file which is critical when it comes to functionality and choosing between root and sudo.
Around the line 27 you will see something like:
# User privilege specification
root ALL=(ALL:ALL) ALL
replace the word root with your username to give it an ability to use sudo.
Hit ctrl+x and exit the file while saving the changes you just made.
4. Test out the sudo
-Open a new terminal and type sudo su
enter your users password and see if it will give you a root access. If everything checks out as ok sudo should be enabled.
5. Lock down the su root access
as a root user (after you have verified that the sudo actually works so that you will not be losing the control of your system permanetely) type the following command:
passwd -l root
You will see a note saying: passwd: password expiry information changed. It means that root password for su root procedure has expired and is locked which leaves sudo as the only way to become root user.
If you wish to re-apply root reverse the steps by changing sudoers entry to root with visudo and do:
when you are a root user after the execution of sudo su command inside a terminal. The above command re-enables root account to be used with the command su root.
Tip: it is always a good thing to keep at least to root terminal open when doing changes to sudoers or root account rights. You will certainly be better prepeared in case an accidental closing of the terminal window might take place. Always remember to test out any changes before you actually close the terminals so that you can be sure that everything works.
Why use sudo: My opinion.
As I have found the case to be sudo is a bit better off when it comes to security of the system. When you have a standard su root account it means that your root username is always labeled as root. This can lead to problems if you system is for some reason compromised and you do not have one of those +15 letters root passwords enabled in your system to keep it safe. When you using sudo your “root” username is your standard username in the system which might make the system harder to crack since your username could be virtually anything. Always do keep in mind that securing a computer is not a trivial task to be taken lightly which means that there is not a single solution to keep your Linux out of harms way. So my advice is: Be cautious what you do and be wise in what you do and keep your software up-to-date.