Is it possible to write a shell script in which we can include the root commands, and execute it without entering the root password over the terminal.
Asked
Active
Viewed 6,439 times
2 Answers
0
Yes.
Some may recommend marking the script as setUID and owned by root. I would discourage this. Instead, put the user under whose ID the script will run into the sudoers group and configure sudo to allow that user to run the specifically required commands as root without requiring that user to enter a password. This provides audibility and keeps things well controlled.
More information on sudo and its configuration can be found here.
David Hoelzer
- 379
0
You can do this by editing your sudoer file.
Open a terminal (ctrl+alt+T)
enter the following command
sudo visudo
Once the file opens enter the following command
username ALL=(ALL) NOPASSWD: /path/to/command
Replace username with the your own username
You can find the path to the command by running
which command
For more information on editing the sudoer file visit this site.