Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a script as root on Mac OS X? [closed]

Tags:

terminal

macos

What should I type on the Mac OS X terminal to run a script as root?

like image 625
Mac Avatar asked Sep 16 '08 17:09

Mac


People also ask

How do I run a script as a 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 ....

How do I run a .sh file in Terminal Mac?

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.


2 Answers

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).

like image 182
dF. Avatar answered Sep 20 '22 13:09

dF.


Or you can access root terminal by typing sudo -s

like image 21
Rob B Avatar answered Sep 17 '22 13:09

Rob B