Sudo Permissions to a script on ubuntu 14.04
18 Apr 2017The sudoers file located at: /etc/sudoers
, contains the rules that users must follow when using the sudo command.
The /etc/sudoers
file controls who can run what commands as what users on what machines and can also control special things such as whether you need a password for particular commands. The file is composed of aliases (basically variables) and user specifications (which control who can run what).
visudo
is utility to edit the /etc/sudoers
file which enable us to configure permissions
User Specifications
User Specifications are where the sudoers file sets who can run what as who.
Format for user specification is as follows
<user list> <host list> = <operator list> <tag list> <command list>
Let is consider the following configuration
pi ALL=(root) NOPASSWD: ALL
This allows user pi
to run any command as root user and it will not prompt for password from the user
beta-dev ALL=(root) /opt/test.ksh
This allows beta-dev users run the ` /opt/test.ksh` script giving root access for script execution
beta-dev ALL=(root) NOPASSWD /opt/test.ksh
This allows beta-dev users run the ` /opt/test.ksh` script giving root access for script execution and this will not ask for a password from the user
References
- https://www.garron.me/en/linux/visudo-command-sudoers-file-sudo-default-editor.html
- https://help.ubuntu.com/community/Sudoers