What should I type on the Mac OS X terminal to run a script as root?
To give root privileges to a user while executing a shell script, we can use the sudo bash command with the shebang. This will run the shell script as a root user. Example: #!/usr/bin/sudo bash ....
Open Terminal, type in sh /path/to/file and press enter. Faster is to type sh and a space and then drag the file to the window and release the icon anywhere on the window.
As in any unix-based environment, you can use the sudo
command:
$ sudo script-name
It will ask for your password (your own, not a separate root
password).
Or you can access root terminal by typing sudo -s
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With