Better than ripping nan cord retired of nan wall!
Key Takeaways
- Linux and macOS systems supply commands specified arsenic shutdown, reboot, halt, and poweroff to safely unopen down aliases restart your machine from nan bid line.
- The commands are shortcuts that constituent to nan systemctl bid successful systemd-based distributions, ensuring compatibility pinch System V init-based systems.
- By utilizing nan shutdown command, you tin schedule shutdowns aliases reboots, supply messages to logged-in users, and cancel scheduled actions utilizing bid statement options.
Feel for illustration starting over? We'll show you really to cleanly and safely reboot aliases unopen down your Linux aliases macOS machine from nan bid line.
What Shutdown Commands Are There connected Linux?
Sometimes you conscionable person to spell for nan reboot aliases nan full shutdown. If you're moving connected a GUI-less server aliases you're connected an SSH convention to a distant computer, nan bid statement is your only option. Linux and Unix-like systems specified arsenic macOS supply respective commands to shutdown aliases reboot your strategy correct from nan bid line.
The commands you tin usage are:
- shutdown
- reboot
- halt
- poweroff
Looking done nan man pages for these commands tin beryllium confusing. Depending connected which bid statement options you choose, each of these commands tin execute shutdowns, reboots, and strategy halts. In fact, nan man pages for reboot, halt, and poweroff incorporate exactly nan aforesaid information.
What's Behind This?
The reply lies successful nan systemd bootstrap strategy which replaced nan venerable System V init system. In nan Linux world, Fedora started to usage systemd successful 2011. Since past it has been adopted by a awesome galore distributions. Debian and Ubuntu swapped to systemd successful 2015.
On systemd -based distributions nan shutdown, reboot, halt, and poweroff commands are efficaciously shortcuts that constituent to nan systemctl command. Retaining these commands provides a grade of compatibility pinch System V init -based distributions. It intends ammunition scripts (and difficult halfway System V strategy administrators) don't keel complete if they are moved to a machine pinch a systemd distribution moving connected it.
Using Shutdown connected Linux
Shutting down aliases rebooting a multi-user strategy intends you person to scheme ahead. You request to determine erstwhile you're going to spell for nan shutdown aliases reboot, and pass nan different strategy users nan shutdown is coming, and when. If it is your ain machine and you're nan only 1 who uses it, life is overmuch simpler.
To tally immoderate of these commands you person to beryllium successful nan sudo group. That is, you must person superuser permissions and beryllium capable to usage nan sudo command. If nan bid you person issued is going to return effect instantly and will not impact different logged successful users, you will not request to usage sudo. If you effort to usage 1 of these commands and nan bid is refused, re-try pinch sudo .
By default nan shutdown bid ensures that each processes are stopped cleanly, each filesystems are synced, and each CPU activity has ceased. This is nan 'halt' state. It past sends a connection to nan hardware to trim disconnected power. This, of course, is nan shutdown aliases "poweroff" state.
It is communal to walk shutdown immoderate parameters, specified arsenic a clip drawstring and a connection that will beryllium sent to nan logged successful users to pass them disconnected nan shutdown. Let's schedule a shutdown for 15 minutes from now. Type shutdown , a space, +15, a space, and past nan connection to nonstop to nan users.
shutdown +15 Shutting down successful 15 minutes!The clip drawstring we utilized was +15 , representing 15 minutes from now. The + is optional. We could person typed 15.
We get a consequence that confirms a shutdown is scheduled and erstwhile it will occur. Logged successful users will person nan connection that we provided.
To cancel a shutdown, usage nan -c (cancel) option.
shutdown -cAlthough you don't get immoderate notification that your shutdown has been canceled, your logged successful users do get notified.
If you don't supply a clip drawstring a shutdown will beryllium scheduled for 1 infinitesimal from now. Note that you can't supply a connection to your logged successful users if you don't specify a clip string.
shutdownIf you can't moreover hold a minute, you tin usage now arsenic nan clip drawstring and nan shutdown takes contiguous effect. Using now is for illustration utilizing +0.
The clip drawstring tin beryllium a group time, specified arsenic 23:00. It must travel nan format of HH:MM and must beryllium successful nan 24-hour clock. Five minutes earlier nan strategy goes down caller logins are prevented.
We cognize nan default action of shutdown makes nan machine spell down to nan halt authorities and past into nan powered disconnected state. We tin override this behaviour by passing different bid statement options to it.
- The -H (halt) action will return your machine down to nan halt authorities but will not inquire nan hardware to powerfulness down.
- The -P (poweroff) is nan default action . The machine is brought down to nan halt authorities and is past powered off.
- The -r (reboot) action will return your machine down to nan halt authorities and past restart it.
- The -h (halt and poweroff) action is nan aforesaid arsenic -P. If you usage -h and -H together, nan -H action takes priority.
- The -c (cancel) action will cancel immoderate scheduled shutdown, halt aliases reboot.
Here's an illustration wherever we person scheduled a reboot.
shutdown -r 08:20 System rebooting astatine 08:20The reboot, halt and poweroff Commands
These commands execute nan action their sanction suggests. However, each of them will judge bid statement options to make immoderate 1 of them execute a reboot, a halt, aliases a poweroff. But why confuse matters? These commands are champion utilized astatine look value.
If you want to reboot now, usage reboot . If you want to poweroff now, usage poweroff, and if you want halt nan strategy now, usage halt.
rebootThese commands return contiguous effect. If immoderate of these commands are refused, precede them pinch sudo. But beryllium aware, a refusal is usually because location are different users logged into nan strategy that you're astir to return offline.
Which Command is Right For Me?
In multi-user environments utilizing shutdown to execute these actions gives you much control. The installation to schedule shutdowns and reboots, and to alert users pinch a broadcast connection will beryllium invaluable successful these cases. For a single-user computer, reboot and poweroff will astir apt meet your needs.