Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Mrfatboy

macrumors 6502
Original poster
Dec 15, 2008
316
6
I want to restart my Mac from terminal. I found the command:

Sudo shutdown -r now

However, this command asks for a password. Is there a way to restart the Mac from the terminal without asking for a password?
 
Your standard user account will not allow the command without invoking admin/root via the 'sudo' and the password prompt. It's a built-in security feature.
 
  • Like
Reactions: Basic75
Is there a way to embed the password in the initial shutdown command?

I can only issue one terminal command to restart the computer.
 
Simple app to immediately restart a Mac:
In Script Editor (/Applications/Utilities/Script Editor.app ) copy-paste

Code:
do shell script "shutdown -r now" user name "YourUserName" password "YourPassword" with administrator privileges

edit YourUserName & YourPassword with your macOS user name and password
Save it as a Run-only app from File > Export (Don’t Code Sign) https://support.apple.com/guide/script-editor/save-a-script-as-an-app-scpedt1072/mac

Apple’s “Restart computers using Terminal on Mac” https://support.apple.com/guide/ter...s-apd7d247a89-3560-4c3b-a471-3e66ff607040/mac

Similar thread
https://forums.macrumors.com/threads/script-to-restart-mac-safely-closing-programs-safely.2336413/
 
  • Like
Reactions: gilby101
Fishrrman "offa-the-wall" thought...

I can't help but think that this thread is somehow related to another thread also currently active in the forum named (something like) "how to prevent Terminal from being launched" ...☠️
 
Fishrrman "offa-the-wall" thought...

I can't help but think that this thread is somehow related to another thread also currently active in the forum named (something like) "how to prevent Terminal from being launched" ...☠️
I can't see why it'd be related at all.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.