How to Run a Shell Script as Superuser
Sunday, October 4th, 2009If you've ever tried to run a shell script as superuser in Linux by using the syntax sudo ./example-shell-script, you'll know that doesn't work. Instead, this is how you need to do it:
- Create your script
vi example-shell-script - Change the permissions
chmod 755 example-shell-script - Switch into superuser mode
sudo su - - Run the script
./example-shell-script - Log out of superuser mode
exit