Skip to content

Instantly share code, notes, and snippets.

@christopheranderton
Created October 19, 2017 18:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christopheranderton/c52ccd1a8355a7f449bfb5b6d831f829 to your computer and use it in GitHub Desktop.
Save christopheranderton/c52ccd1a8355a7f449bfb5b6d831f829 to your computer and use it in GitHub Desktop.
CLI OS X/macOS: Shutdown, Restart and Sleep Commands
# Classic BSD Style
#---------------------------------------------------------------
# Shutdown hardcore style
sudo shutdown -h now
# Shutdown at once hardcore style
sudo shutdown -r now
# Shutdown hardcore style in 30 minutes
sudo shutdown -h +30
# Sleep
#---------------------------------------------------------------
# Go to sleep
pmset sleepnow
# Put display to sleep
pmset displaysleepnow
# Using AppleScript in Terminal
#---------------------------------------------------------------
# Shut down after showing a confirmation dialog
osascript -e 'tell app "loginwindow" to «event aevtrsdn»'
# Restart after showing a confirmation dialog
osascript -e 'tell app "loginwindow" to «event aevtrrst»'
# Log out after showing a confirmation dialog
osascript -e 'tell app "System Events" to log out'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment