I have a simple shutdown script which i want to run as root
shutdown -h +30;
echo "succesfull";
I have followed these answer1,2 to make my script root.
first I run this command
sudo chown root.root $HOME/test/test.sh
sudo chmod 4755 $HOME/test/test.sh
and then made changes in sudoers
sudo visudo
added this command after this line %sudo ALL=(ALL:ALL) ALL
eka ALL=(ALL) NOPASSWD: $HOME/test/test.sh
But when i executed my script its showing this error
shutdown: Need to be root
succesfull
chmod 4755
- I assume you meant to make a setuid script? Scripts can't be made setuid.sudo chmod +x $HOME/test/test.sh
chmod u-s
, but as I said, it doesn't matter - setuid doesn't affect scripts.