Most computers (and OSes) will automatically go into sleep mode when it has been idle for some time. This can be useful in reducing power consumption and extending the life span of your hardware. However, it can be frustrating when the computer goes to sleep while you are watching a movie, or just listen to songs.
In Mac, there are several apps that you can install to prevent the system from “sleeping”, however, these apps are mostly unnecessary because you can easily do so with this command.
Open the terminal and type:
This command will prevent your Mac from sleeping. To stop it, simply press “Ctrl + c” to terminate it.
Note: This is only a quick example of what
caffeinate can do. You can also append
-t flag for more advanced option.