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.
We can shutdown a Linux system with poweroff command. If we want to fore the shutdown we can use -f parameter. I we want to restart system we can provide –reboot parameter.
Halt command change system run level by using systems service manager like systemd or service.
Command reboot can be used to poweroff the system without restarting.
$ reboot --halt
- To shutdoown system –halt parameter should be provided.
Shutdown System After Given Time
We can set timer to shutdown system. Say we want to shutdown system after 5 minutes.
$ 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.
$ shutdown -h +5 "System will be shutdown after 5 minutes"