Using Sudo (Visudo)

You wanna grant root privileges to a normal user account in Linux without updating the user id’s and file/folder permissions? Then the best way is to use sudo operations on commands. Before enabling sudo, create a user account with a password. Once the user account is created, login the shell with the root user and issue the command: visudo
This will open /etc/sudoers file. You use “visudo” to edit the sudoers file. There are two reasons for that- it prevents two users from editing the file at the same time, and it also provides limited syntax checking. Even if you are the only root user, you need the syntax checking, so use “visudo”.
Once this file is open, search for this particular line:

root ALL=(ALL) ALL

Copy that line and paste the same below and edit the user root to the user account that you created.

For eg: user ALL=(ALL) ALL

Save the file and thats it.

Now, login to the shell with a new user account and if you see “permission denied” prompt for any command that you issue, you can use sudo prior to the command.

For eg: sudo cat /etc/shadow

Unless you use “sudo” operator, the command won’t work for a normal user account.

Advertisements