Sleep the Display
Disclaimer: This is an old post. Content may be out of date.
The pmset
utility can be used to sleep the display of a Mac from the command line. This can be useful for locking a Mac remotely if its security settings are configured to require a password after waking, but without needing to put the Mac fully to sleep:
pmset displaysleepnow
If you do want to put the Mac to sleep, rather than just sleeping the display, just use sleepnow
instead:
pmset sleepnow