Linux Tutorials - Herong's Tutorial Examples - v5.34, by Dr. Herong Yang
"sudo" Command and Privilege
Provides a tutorial example on how to grant 'sudo' privilege to a user to allow him/her to run 'sudo' command to gain 'root' permission without login as 'root'.
What Is "sudo" Command? "sudo" command allows to temporarily run a command with "root" administrative right. The basic syntax of the "sudo" command is:
The above command will prompt for your password. Once provided, the system runs the given sub-command under the "root" permission. This is a much safer way than login as "root" to run the given sub-command.
In order to run "sudo" command, the user must be granted with the "sudo" privilege first. This can be done in different ways.
1. Adding the user to the "wheel" group on RedHat, CentOS and similar systems:
(login as root) root# usermod -aG wheel herong
2. Adding the user to the "sudo" group on Debian, Ubuntu and similar systems:
(login as root) root# usermod -aG sudo herong
You can verify your sudo privilege by running the "sudo id" command.
(login as herong) herong$ id uid=1000(herong) gid=1000(herong) groups=1000(herong),10(wheel)... herong$ sudo id (enter herong's password) uid=0(root) gid=0(root) groups=0(root)
To remove the "sudo" privilege, you can remove the user from the "wheel" or "sudo" group.
herong$ sudo gpasswd -d joe wheel herong$ sudo gpasswd -d joe sudo
Table of Contents