Lagos, Nigeria

How to Lock Your Mac Using Terminal

Mac Terminal App Icon

One of the first rules of cybersecurity is to always lock your computer before stepping away from it. While it might not be the quickest way, you can lock your Apple Mac using Terminal. Here’s how to do it.

Require a Password to Unlock Your Mac

The command to lock your Mac using Terminal doesn’t actually lock it. Rather, it just puts it to sleep. To be considered “locking,” a password must be required to access a Mac after it’s been put to sleep.

To password-protect your Mac after it’s been put in sleep mode, click the Apple icon at the top left of the menu bar, and then select “System Preferences.”

Here, click “Security & Privacy.”

Under the “General” tab, select the checkbox next to “Require Password.”

Type your password, and then click the arrows next to “Require Password” to open the drop-down menu. You can then select the amount of time that must pass before a password is required. Select “Immediately” to lock your Mac whenever you put it to sleep.

With this enabled, your Mac will immediately lock whenever it’s put to sleep.

Lock Your Mac Using Terminal

To lock your Mac via Terminal, you first have to launch it. Press Command+Space to open Spotlight Search. Type “Terminal” in the Search bar, and then click it when it appears in the search results.

In Terminal, type the following command, and then press Enter:

pmset displaysleepnow

Your Mac will now be in sleep mode. If you selected the option to require a password to wake it, it is now also effectively locked.

Locking your Mac is a good way to prevent unauthorized access to it, while still allowing programs to run in the background. If you’d rather kill all operations, you can also shut down your Mac via Terminal.

RELATED: How to Lock Your Windows 10 PC Using Command Prompt

This post was written by Marshall Gunnell and was first posted to

Do you find this article helpful? Your Friend might too. So, please Share it with them using the Share button above.
Will you like to get notified when I post new updates? Then Follow me on any of my social media handles: Google News, Telegram, WhatsApp, Twitter, Facebook, Pinterest.
You can also drop your email address below if you wish to be notified by mail.

[newsletter_form type="minimal" lists="undefined" button_color="undefined"]

Tags: ,