There is no easy way to hibernate a macOS computer on demand. This utility fixes that problem. This command must be run as root, but there's an easy way to fix that:
- Copy
deepsleep.shto a folder, such as/usr/bin(In Terminal, typecp /PATH/TO/deepsleep.sh /usr/bin) - In Terminal, type:
sudo visudoto edit the/etc/sudoersfile. DO NOT edit this file with another command. If you do not likeviyou can typeexport VISUAL=nanofirst to tellvisudoto usenano - Add a line anywhere in the file (I recommend either the very beginning or very end) that says
ALL ALL=NOPASSWD:/LOCATION/TO/deepsleep.sh(so, for example,ALL ALL=NOPASSWD:/usr/bin/deepsleep.sh) - Run the command using
sudo /path/to/deepsleep.sh
If you wake the computer before it's finished hibernating, this script will leave it in a bad spot where it will hibernate every time you tell it to go to sleep. To fix this, type sudo pmset -a hibernatemode 3 or sudo path/to/deepsleep.sh fix into Terminal.