I am new to Linux and I have installed some Linux distributions. I try to learn bash commands. I can shutdown my computer from Desktop manager easily. But How can I shutdown system from bash without a GUI. There are different ways to shutdown Linux system. Following commands will work most of the distributions like Ubuntu, Debian, Mint, Kali, CentOS, RedHat, Fedora.
$ sudo poweroff 使用关机命令关机后重新启动 (Reboot After Shutdown with Poweroff Command)
poweroff command provides the --reboot option which will start the Linux system after a shutdown.
poweroff命令提供了--reboot选项,它将在关机后启动Linux系统。
$ sudo poweroff --reboot 停止 (Halt)
halt command change system run level by using systems service manager like systemd or service.
通过使用系统服务管理器(如systemd或service)来halt命令来更改系统运行级别。
$ sudo halt 重启命令 (Reboot Command)
reboot command actually a synonym of the poweroff command with --reboot option. We can use--halt option in order to halt and do not restart the system like below.
To shutdown system –halt parameter should be provided.
要关闭系统,应提供-halt参数。
关机命令 (Shutdown Command)
The most popular and well known command is shutdown command. This command automatically shutdown the current system.
最受欢迎的命令是shutdown命令。 该命令自动关闭当前系统。
$ sudo shutdown 给定时间后关闭系统 (Shutdown System After Given Time)
We can set timer to shutdown system. In this example we will shutdown the system after 5 minutes the command issued.
我们可以设置定时器来关闭系统。 在此示例中,我们将在发出命令5分钟后关闭系统。
$ sudo shutdown -h +5 关闭前向系统用户发送消息 (Send Message To The System Users Before Shutdown)
We can send message to the system users with shutdown command. This is useful is we give some time and send message to provide this information to the system users. In this example we will send the message System will be shutdown after 5 minutes
我们可以使用shutdown命令将消息发送给系统用户。 这在我们花一些时间并发送消息以将这些信息提供给系统用户时很有用。 在此示例中,我们将发送消息, System will be shutdown after 5 minutes
$ sudo shutdown -h +5 "System will be shutdown after 5 minutes"
LEARN MORE Useful Linux Commands
了解更多有用Linux命令
如何关闭Linux系统信息(How To Shutdown Linux System Infografic)