If you want to shutdown your Mac computer or Laptop (Macbook) using the Terminal command then you can make use of the shutdown or the halt command, note that this is special command and will require sudo rights in order to execute it.
Let's see few examples of this command,
Shutdown Mac using shutdown command
Let's read the manual first to understand this command and its syntax,
% man shutdown
NAME
shutdown -- close down the system at a given time
SYNOPSIS
shutdown [-] [-h [-u] | -r | -s | -k] [-o [-n]] time [warning-message ...]
DESCRIPTION
The shutdown utility provides an automated shutdown procedure for super-users to
nicely notify users when the system is shutting down, saving them from system administrators,
hackers, and gurus, who would otherwise not bother with such niceties,
The following options are available:
-h The system is halted at the specified time.
-k Kick everybody off. The -k option does not actually halt the system, but
leaves the system multi-user with logins disabled (for all but super-user).
-n If the -o is specified, prevent the file system cache from being flushed by passing
-n option to halt(8) or reboot(8). This option should probably not
be used.
-o If -h or -r is specified, shutdown will execute halt(8) or reboot(8) instead
of sending a signal to launchd(8).
-r The system is rebooted at the specified time.
If you try the command without sudo you will get error: NOT super-user
% shutdown 5
shutdown: NOT super-user
Let's say you want to shutdown your Mac in the next 60 minutes (an hour) you can use the below command,
user@mac ~ % sudo shutdown -h 60
Password:
shutdown: bad time format
user@mac ~ % sudo shutdown -h +60
Shutdown at Sun Jun 13 13:48:36 2021.
shutdown: [pid 2875]
user@mac ~ %
*** System shutdown message from code2care@mac.local ***
System going down at 13:48
Note that if you do not provide the + sign for a time in minutes provided you will get an error saying bad time format. As you can see that a PID is provided to you as well as the exact time in HH:mm when the system will be shut down. If you wish to revoke this you can kill the process to avoid shutdown.
If you to instantly shutdown your Mac you can make use of the now option,
% sudo shutdown -h now
![Shutdown Mac using Terminal Shutdown Mac using Terminal](https://code2care.org/macos/shutdown-mac-terminal-command/images/Shutdown Mac using Terminal.png)
Shutdown Mac using halt or reboot command
Again, its also good to read the manual to better understand the command,
NAME
halt, reboot -- stopping and restarting the system
SYNOPSIS
halt [-lnqu]
reboot [-lnq]
DESCRIPTION
The halt and reboot utilities flush the file system cache to disk, send all running
processes a SIGTERM (and subsequently a SIGKILL) and, respectively, halt or restart
the system. The action is logged, including entering a shutdown record into the
wtmp(5) file.
When the system is halted with the halt command, the system is powered off.
The options are as follows:
-l The halt or reboot is not recorded in the system log. This option is
intended for applications such as shutdown(8), that call reboot or halt and
log this themselves.
-n The file system cache is not flushed. This option should probably not be
used.
-q The system is halted or restarted quickly and ungracefully, and only the
flushing of the file system cache is performed (if the -n option is not spec-
ified). This option should probably not be used.
-u The system is halted up until the point of removing system power, but waits
before removing power for 5 minutes so that an external UPS (uninterruptible
power supply) can forcibly remove power. This simulates a dirty shutdown to
permit a later automatic power on. OS X uses this mode automatically with
supported UPSs in emergency shutdowns.
Normally, the shutdown(8) utility is used when the system needs to be halted or
restarted, giving users advance warning of their impending doom and cleanly terminat-
ing specific programs.
Examples:
% sudo halt
Have Questions? Post them here!
- Fix: grunt: command not found (Mac/Windows)
- AppleScript Example with TextEdit
- How to copy Password of Wifi on your Mac
- Install OpenJDK Java (8/11/17) versions using brew on Mac (Intel/M1/M2)
- How to check if a port is in use using terminal [Linux or macOS]
- Cut, Copy and Paste Keyboard Shortcuts on Mac Keyboard
- [macOS] NetBeans IDE cannot be installed. Java (JRE) found on your computer but JDK XX or newer is required.
- How to Remove Widgets from macOS Sonoma 14 Desktop
- Turn off Auto-Capitalization on macOS Ventura 13
- How to Go To /usr/local/bin on Mac Terminal?
- How to Open TextEdit on Mac
- Mac: How to Open Android Studio from Terminal
- How to change the default location of Mac Screenshot
- Display Seconds in Digital Clock on Mac Menu Bar [macOS]
- How to install homebrew (brew) on M1 Mac
- Must Know Homebrew Commands for Mac/Linux Users
- Steps to Uninstall Roblox on Mac (macOS)
- How to change the System Settings Sidebar icon size Mac Ventura 13
- How to set Out Of Office (OOO) on Outlook for Mac [Updated 2023]
- Trigger Notification Center Message using Mac Terminal Command
- [fix] macOS Ventura - Python3 xcrun: error: invalid active developer path missing xcrun at CommandLineTools
- How to Install Rust Language on Mac (macOS)
- How to minimize all Windows in Mac
- Display ls command file sizes in KB (kilobytes) MB (megabytes) or GB (gigabytes) [Linux/macOS]
- How to make TextEdit the default text Editor on Mac
- How to run Java Unit Test cases with Apache Maven? - Java
- Notepad++ Happy vs Unhappy Versions - NotepadPlusPlus
- How to disable Wallpaper Tinting on macOS Sonoma 14 - MacOS
- List of Java JDK Major Minor Version Numbers - Java
- AWS CLI Change Default Output Format - AWS
- How to Skip or Ignore JUnit test cases in Java - Java
- Online JSON Validator Tool - Tools
- 42: Take a string as input and print its length. [1000+ Python Programs] - Python-Programs