How to Shutdown a Mac from Terminal - Haxiphone-Easy Hacks iphone All Os

Latest

সোমবার, ২১ আগস্ট, ২০১৭

How to Shutdown a Mac from Terminal

Terminal in macOS
Advanced Mac users may wish to shut down a computer from the command line. This can be helpful for remote administration with ssh, in situations where a Mac is booted into Single User Mode, or many other circumstances of troubleshooting and systems administration.
There are several ways to shut down a Mac from the command line, we’ll cover two of the most simple methods using easy syntax.

The Mac Terminal offers many commands for handling various tasks and system functions, and so naturally the command line also offers a method to shutdown a Mac computer from the Terminal as well.
An important word of warning: shutting down a Mac through the command line happens instantaneously. There is no confirmation, no warning dialog, no stopping to save documents, no asking to close apps or save anything. Instead, the Mac will instantly terminate any and all activity going on and immediately shut down the computer. This could lead to data loss, so be sure you are ready to turn off a Mac if you issue these commands.

Shutting Down a Mac from Command Line with ‘shutdown’

Apt for the name, the ‘shutdown’ command can shutdown a Mac as well as reboot a Mac via Terminal. To turn off a Mac with the shutdown command, you will use the -h flag and give the time for ‘now’ making the syntax like so:
sudo shutdown -h now
As soon as you hit return and authenticate the command, the Mac halts and kills all applications and processes and shuts the computer down. There is no warning and no dialog, it happens instantly.
Unless you’re actively logged in as the root user (via single user or otherwise), you will need to prefix the shutdown command with ‘sudo’ to give the command superuser privileges, thus requiring an administrative password.
If you feel like trying this yourself (and you have all data saved and nothing important open) do the following:
  1. Open the Terminal in Mac OS (found in /Applications/Utilities/ folder)
  2. Enter the following command syntax exactly:
  3. sudo shutdown -h now
  4. Hit the return key and authenticate with an administrative password to immediately shut down the Mac
Shutdown a Mac from Command Line
The Mac will immediately shut down. No data is saved and no dialogs are confirmed, the shut down happens instantly.
You can also use the -h flag to set a time or date for shutting down the computer, for example in 30 minutes, but if you want to shut down the Mac instantly you would use the ‘now’ parameter with the -h flag rather than a number.

Shutting down a Mac in XX Minutes from the Command Line

If you do feel like putting a delay on the shutdown, you can use the following command syntax instead:
sudo shutdown -h +30
Replace “30” with any other number of minutes to shut down the Mac in that amount of time. For example if you put “2” instead of 30 then you would shut down the Mac in 2 minutes.

Shutting Down a Mac via Terminal with ‘halt’

The ‘halt’ command can also instantly shut down a Mac via the command line. The process and syntax for ‘halt’ to turn off a Mac is as follows:
  1. Open the Terminal .app in Mac OS
  2. Enter the halt command syntax exactly as described:
  3. sudo halt
  4. Hit the return key, authenticate with sudo to instantly shut down the Mac
Whether you use ‘halt’ or ‘shutdown’ does not matter really, it’s mostly preference and what you can remember when necessary.
By the way, the shutdown command can also be also be used to restart a Mac from the command line by using the -r flag instead of the -h flag.
Keep in mind that for most users the command line approach is not going to be better or faster than accessing the  Apple menu Shut Down option or using the power button keyboard shortcuts, this is really aimed at advanced users who are already at the command line anyway.

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন