- Перезагрузка компьютеров с помощью Терминала на Mac
- Перезагрузка локального компьютера
- Немедленная перезагрузка удаленного компьютера
- Перезагрузка удаленного компьютера в определенное время
- Автоматическая перезагрузка при сбое питания
- Как отключить Mac от терминала 2021
- Маша и Медведь (Masha and The Bear) — Подкидыш (23 Серия)
- Выключение Mac из командной строки с помощью «shutdown»
- Выключение Mac через XX минут из командной строки
- Завершение работы Mac через терминал с помощью ‘halt’
- 2 Ways To Shutdown Mac from Terminal
- How to Shut Down a Mac from Terminal
- How to Shutdown Mac from Command line After Certain Time
- Power off Mac from Terminal using the ‘halt’ Command
- How to Shutdown a Mac from Terminal
- Shutting Down a Mac from Command Line with ‘shutdown’
- Shutting down a Mac in XX Minutes from the Command Line
- Shutting Down a Mac via Terminal with ‘halt’
- Related
- Enjoy this tip? Subscribe to our newsletter!
- Thank you!
- Related articles:
- 19 Comments
Перезагрузка компьютеров с помощью Терминала на Mac
Чтобы перезагрузить компьютер немедленно или в определенное время с помощью приложения «Терминал», используйте команду shutdown или systemsetup . В следующих примерах показано несколько способов использования этих команд. Полная информация о них приведена на man-странице команды shutdown и man-странице команды systemsetup.
Совет. Можно легко перезагрузить Mac, выбрав меню «Apple»
> «Перезагрузить», или выключить компьютер, выбрав меню «Apple» > «Выключить». См. раздел Выход из системы, переход в режим сна, перезагрузка и выключение Mac.
Перезагрузка локального компьютера
В приложении «Терминал» на Mac введите следующую команду:
Немедленная перезагрузка удаленного компьютера
В приложении «Терминал» на Mac введите следующие команды:
Вместо admin укажите короткое имя учетной записи пользователя на удаленном компьютере.
Вместо computer укажите IP-адрес или имя хоста удаленного компьютера.
Перезагрузка удаленного компьютера в определенное время
В приложении «Терминал» на Mac введите следующие команды:
Вместо admin укажите короткое имя учетной записи пользователя на удаленном компьютере.
Вместо computer укажите IP-адрес или имя хоста удаленного компьютера.
Вместо hhmm укажите время перезагрузки удаленного компьютера (в формате ччмм).
Автоматическая перезагрузка при сбое питания
В приложении «Терминал» на Mac введите следующую команду:
Вместо seconds укажите количество секунд, по прошествии которых компьютер должен загружаться после сбоя питания. Значение должно быть равно 0 (нуль) или быть кратно 30.
Примечание. Можно также задать настройки энергосбережения, чтобы компьютер Mac автоматически перезагружался после сбоя питания.
Источник
Как отключить Mac от терминала 2021
Маша и Медведь (Masha and The Bear) — Подкидыш (23 Серия)
Опытные пользователи Mac могут отключить компьютер из командной строки. Это может быть полезно для удаленного администрирования с помощью ssh, в ситуациях, когда Mac загружается в однопользовательском режиме, или во многих других случаях устранения неполадок и системного администрирования.
Есть несколько способов выключить Mac из командной строки, мы рассмотрим два самых простых метода с использованием простого синтаксиса.
Терминал Mac предлагает множество команд для обработки различных задач и системных функций, поэтому, естественно, командная строка также предлагает способ выключения компьютера Mac из Терминала.
Важное предупреждение: выключение Mac через командную строку происходит мгновенно. Нет подтверждения, нет предупреждения, нет остановки для сохранения документов, нет запроса на закрытие приложений или сохранение чего-либо. Вместо этого Mac мгновенно прекратит все действия и немедленно выключит компьютер. Это может привести к потере данных, поэтому убедитесь, что вы готовы выключить Mac, если вы выполните эти команды.
Выключение Mac из командной строки с помощью «shutdown»
Выбрав имя, команда «shutdown» может выключить Mac, а также перезагрузить Mac через терминал. Чтобы выключить Mac с помощью команды shutdown, вы будете использовать флаг -h и дать время для «сейчас», сделав синтаксис следующим образом:
sudo shutdown -h now
Как только вы нажмете клавишу возврата и подтвердите подлинность команды, Mac останавливает и убивает все приложения и процессы и выключает компьютер. Там нет ни предупреждения, ни диалога, это происходит мгновенно.
Если вы не вошли в систему как пользователь root (с помощью одного пользователя или иным образом), вам нужно будет поставить команду shutdown перед ‘sudo’, чтобы дать привилегии суперпользователя команды, таким образом, требуя административный пароль.
Если вы хотите попробовать это самостоятельно (и у вас есть все данные, сохраненные и ничего важного не открыто), сделайте следующее:
- Откройте Терминал в Mac OS (находится в папке / Applications / Utilities /)
- Введите следующий синтаксис команды точно:
sudo shutdown -h now
Mac немедленно выключится. Данные не сохраняются и диалоги не подтверждаются, отключение происходит мгновенно.
Вы также можете использовать флаг -h, чтобы установить время или дату для выключения компьютера, например, через 30 минут, но если вы хотите немедленно выключить Mac, вы бы использовали параметр «сейчас» с флагом -h, а не чем число.
Выключение Mac через XX минут из командной строки
Если вы чувствуете, что хотите задержать выключение, вы можете использовать следующий синтаксис команды:
sudo shutdown -h +30
Замените «30» на любое другое количество минут, чтобы выключить Mac за это время. Например, если вы поставите «2» вместо 30, вы выключите Mac через 2 минуты.
Завершение работы Mac через терминал с помощью ‘halt’
Команда ‘halt’ также может мгновенно завершить работу Mac через командную строку. Процесс и синтаксис «остановки» для отключения Mac выглядит следующим образом:
- Откройте Терминал .app в Mac OS
- Введите синтаксис команды halt точно так, как описано:
Используете ли вы «останов» или «выключение» не имеет значения на самом деле, это в основном предпочтения и то, что вы можете помнить, когда это необходимо.
Кстати, команда shutdown также может быть использована для перезагрузки Mac из командной строки, используя флаг -r вместо флага -h.
Имейте в виду, что для большинства пользователей подход с использованием командной строки не будет лучше или быстрее, чем доступ к параметру «Apple» «Выключение» или использование сочетаний клавиш на кнопке питания, он действительно предназначен для опытных пользователей, которые уже находятся в командной строке. тем не мение.
Источник
2 Ways To Shutdown Mac from Terminal
If you own an advanced Mac for business or personal use, chances are you may want to shut it down directly from the command line. This comes handy when you need to remote control your Mac, especially in conditions when you Mac device is booted with the Single User Mode or circumstances of systems administration and troubleshooting. Read on to learn how to Shutdown Mac from terminal easily.
There are many methods that you can use to completely shut down a Mac using the command line. In this article, we will tell you about the two easiest methods.
The Mac Terminal listens to a lot of commands to manage a plethora of tasks and system functions. So, it is but obvious that the command line also comes with methods to easily shut down a Mac computer from the Terminal.
Please bear in mind that the shutting down of the Mac device using the command line method takes place almost immediately. There’s absolutely no warning dialog, no confirmation or any way to stop the process after the command has been given. So, any unsaved data will be lost if the apps close suddenly.
How to Shut Down a Mac from Terminal
The shutdown command helps you to shut down as well as reboot a Mac using the Terminal. If you want to close down all the operations and shut down Mac then you will need to use the h flag and give it the command to shut the system immediately. So, the syntax line will be something like this – sudo shutdown -h now
When you hit the return button and validate the command, the Mac will come to a halt and forcefully stop all the processes and applications. There will no dialog or warning before the action takes place.
Unless you have actually logged in to the computer as the root user, you will need to preface the shutdown command by adding ‘sudo’ which means this needs an administrative password.
To shutdown Mac from terminal follow the steps given below:
1. Open the Terminal on you Mac OS device.
2. Enter the following syntax command below:
sudo shutdown -h now
3. When you are done, you can simply hit the return key and then authenticate the command using an administrative password to enable you to immediately shut down the Mac.
How to Shutdown Mac from Command line After Certain Time
If you want to shutdown a Mac from Terminal after a specified time, you can do that easily using the command below:
sudo shutdown -h +60
After that, you will be asked to enter your password and confirmation that your Mac will be powered off in 60 minutes (in our case).
Your Mac will be powered off after 1 hour (60 minutes). You can replace the “60” number with any number converted in minutes.
Power off Mac from Terminal using the ‘halt’ Command
If you want to shut down the Mac device immediately, you need to give the ‘halt’ command to do so. Below we have given the process and syntax that can be used to close down a Mac. To do this you need to first open the terminal app in your Mac OS device. The command will be:
When you are done, simply hit the return key and then validate the sudo to instantaneously shutting down the Mac. It’s entirely up to you whether you want to use the ‘shutdown’ or ‘halt’ command as it’s all up to preferences.
We hope the above two methods help you shutdown a Mac from Terminal almost instantly.
Источник
How to Shutdown a Mac from Terminal
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:
- Open the Terminal in Mac OS (found in /Applications/Utilities/ folder)
- Enter the following command syntax exactly:
sudo shutdown -h now
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:
- Open the Terminal .app in Mac OS
- Enter the halt command syntax exactly as described:
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.
Related
Enjoy this tip? Subscribe to our newsletter!
Get more of our great Apple tips, tricks, and important news delivered to your inbox with the OSXDaily newsletter.
Thank you!
You have successfully joined our subscriber list.
Related articles:
19 Comments
It’s just like windows they have shutdown commsnd when you updating the windows patches.i got no time to wait to shutdown i just type the command on search button or you cmd .
this is just basic commsnd for unix wait until you need to search some hidden files more command. 20 years ago mac os purely unix command when it comes restore the mac but now apple make it simple .
Great tip I learned how to shut down the Mac from the command line with this. I use to use shutdown -h now in Linux but had long forgotten the commands.
Today we have only seven ladder manufacturers in the US, down from >100. Why; not globalization, nor a decline in the market but rather the lawsuits from people who fell off ladders and sued all the small operations. The desire for an idiot-proof world is here again on this thread. CLI and its risk/benefits are not for the foolhardy. People like this are the reason why construction trucks make that beeping noise when backing-up.
The “reboot” command was not listed, but is sometimes very handy.
Well, for those of us who use the Terminal this trick is appreciated. Thank you.
This advice is just plain wrong and will lead to corruption and lost data if you follow it. DO NOT follow this advice.
Both commands send programs a UNIX style shutdown command. GUI programs do not expect this and will terminate WITHOUT giving you the chance to save your data or clean themselves up. (Specifically, Cocoa apps do not see applicationShouldTerminate: or the kAEQuitApplication Apple Event)
The correct way to safely shutdown from the command line is “osascript -e ‘tell app “System Events” to shut down’”
Sam, you’re wrong. This shuts down a Mac from the command line. Did you even bother read the article? Obviously not. There are multiple warnings that it does not request a data save. There’s a giant paragraph at the beginning of the article.
How did you manage to get this far without reading the article? Maybe this site needs a system to verify that people read the article before they can comment.
“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.”
Also to say it is “wrong” is itself wrong, because “wrong” is by definition incorrect. The article is correct, even if you don’t agree with it. That makes it TRUE.
Why don’t you do your own research, type “man shutdown” into the command prompt and you will see that it is REAL and TRUE. Facts matter.
You are wrong about reading the man page. The man page was never updated for macOS. Read the bottom of the man page. It says “BSD December 11, 1998”. That means Apple never updated the man page for OS X, otherwise it would say DARWIN or macOS (try man diskutil or pmset). Therefore do NOT trust the information.
There is NO reason to use BSD shutdown unless the system is stuck. There is a perfectly good command line method which I provided, which is safe and does not result in data loss.
In general, Apple does recommend applications or users work with the BSD interfaces and utilities in macOS. This is a prime example why.
Sam if you’re booted into recovery or single user as root and need to shutdown a Mac, how do you propose doing that?
The answer is the shutdown command.
I use `osascript -e ‘tell app “System Events” to shut down’` and worked just fine.
“*** FINAL System shutdown message from user@host ***
System going down IMMEDIATELY”
Then I had to go across town to locally switch it back on. Any osascript magic to switch the machine back on, remotely?
If you haven’t found it already, you’re going to groan a bit.
osascript -e ‘tell app “System Events” to restart’
This is idiotic, why risk a terminal mistake when you can simply go to Apple upper left of screen and click shut down. If you are connected remotely this works exactly the same.
I guess OSXDaily is just running out of good advice, and posting bad in it’s place.
“no way” you personally should definitely stick to novice level material like your little Apple menu trick because this is obviously over your head, which is fine, you’re a novice level user. Everyone starts somewhere.
If you don’t know why people use the Terminal or would want to shutdown from the command line you should probably not comment about it, it makes you sound even less intelligent than your comments already are.
Actually shutting down a Mac by command is very useful to every sysadmin.
If you don’t understand a subject but you attack that subject because you don’t understand it yourself, that makes you the idiot. You’re being willfully ignorant. In fact, you would be less of an idiot yourself if you bothered to learn a thing or two.
I understand the subject perfectly well, have been a system admin and senior level repair for Apple for over two decades.
Instead of whining and trash talk prove me wrong.
Bottom line doing ANYTHING via terminal remotely is a risk that no experienced tech would ever do when they can do it via the user commands.
Well… your nick certainly suits you… because there is NO WAY you’ve been a sysadmin for over two decades and haven’t happened upon a situation where you’ve needed to shutdown a Mac via the CLI.
For one, as a true sysadmin, I SSH into our Macs (typically moreso the servers – Minis, etc – but also the workstations on occasion), and shutting down/restarting via command line is the quickest option.
For two, it’s what a true sysadmin would be used to, having administered mixed platform environments including *NIX, Windows and Mac systems.
For three, using the shutdown command via the terminal CLI is no more “dangerous” than choosing the wrong menu item or clicking the wrong button on a GUI… and it’s 10x’s more efficient because I don’t have to stop and reach for a mouse.
So, really, you’re definitely not inspiring confidence in your sysadmin skills right now… especially if you don’t think you can accurately type an 8 letter command in a terminal.
obviously if you are using this method is because the regular one did not work! duh
you’re wrong…
I just used the command as the top bar did not want to pop up. Shutting down with the buton is not too healthy for the HDD.
Источник