How To Shutdown Linux System

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.

Poweroff Command

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.

1

$poweroff

Halt

Halt command change system run level by using systems service manager like systemd or service.

1

$halt

Reboot

Command reboot can be used to poweroff the system without restarting.

1

$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.

1

$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.