If you want to stop your Mac sleeping, there's a couple of ways you can go about it. The first and most obvious way is to go through the System Preferences Power menu and change the amount of time until the Mac goes to sleep to "Never".
However, there is a common scenario where that method just won't work: if you don't have system admin rights. The Power menu, where you adjust the sleep timer preferences, can be locked behind an administrator password. If you're on a machine managed by an employer (like me), or you're using a Mac owned by someone else, you may not be able to change the display timer settings. For me, this leads to my MacBook Pro always going to sleep after 2 minutes when I'm not plugged in.
Thankfully, there's a way you can get around this using a simple Terminal command.
Here's how to stop your Mac sleeping using Terminal.
How to stop your Mac sleeping using 'caffeinate' in Terminal
1. Open Terminal. If you're not sure how, read our guide on how to open Terminal on Mac (opens in new tab).
2. Type "caffeinate" and hit Enter.
And you're done. Your Mac will now stay awake as long as you don't close the lid on a MacBook. To decaffeinate, with the Terminal window open, press Cmd + W and click Terminate.
Now that you know how to stop your Mac sleeping, why not read our other macOS guides. We can show you how to clear the cache on Mac and how to reset the SMC on a MacBook Pro — both will help you speed up a sluggish Mac. We can also show you how to change the screenshot location on Mac and how can you set default apps on Mac.
Next: learn how to use the Automator on Mac to simplify your processes.