Oct 20, 2018

[HDGEM] How To Give a Linux User Root-level Access Using sudo

root@host [~]# visudo
This will open the sudoers file in the vi editor. In order to give the user full root privileges, add the following line to the file:
example ALL=(ALL) ALL
If you only want a user to run certain commands as root, you can create a command alias in your sudoers file, like so:
User_Alias ADMINS = example
Cmnd_Alias HTTPD = /etc/init.d/httpd

User_Alias creates a group of users that you can then assign command aliases to. (Additional users can be listed on the same line, separated by commas.) Cmnd_Alias then lists the various commands that the users of that Alias can run. The user alias is then assigned the command alias. The example user is now able to run the apache init script with full root privileges, which allows him to start, stop, and restart apache.
With this configuration, the user will have to type in his own password when he wishes to run sudo. If you don't need the user to type a password every time he runs a sudo command, just replace the last line of the above with:

This should get you started applying sudo privileges to your users. If you have more detailed needs, the man page for sudo is thorough and readable. The sudoers file has a separate man page that details all the configuration options.

Posted By Blogger to HDGEM at 1/25/2017 07:01:00 AM