January 25, 2017

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

[email protected] [~]# 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
ADMINS ALL = 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:
ADMINS ALL = NOPASSWD: HTTPD

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
Post a Comment

Featured Post

Updated Coupons / promo codes for Google Apps for Work / Business

To redeem: 1. Sign up for Google Apps   2. Go to your billing settings  3. Choose your payment plan  4. Enter your promo code ...