You can shut down a Linux system using the command line by using the shutdown command. The basic syntax is as follows:
sudo shutdown [OPTIONS] [TIME] [MESSAGE]
OPTIONS: There are several options you can use to specify how the shutdown process should proceed. For example, you can use the-hor--haltoption to halt the system after shutting down, or the-ror--rebootoption to reboot the system after shutting down.TIME: This is the time in minutes until the shutdown process is initiated. If you specifynow, the shutdown process will start immediately.MESSAGE: This is an optional message that will be broadcast to all users on the system.
Here are a few examples of how to use the shutdown command to shut down a Linux system:
- To shut down the system immediately:
sudo shutdown now
- To shut down the system in 5 minutes:
sudo shutdown +5
- To shut down the system in 5 minutes and display a message to all users:
sudo shutdown +5 "The system will shut down in 5 minutes. Please save your work."
- To reboot the system immediately:
sudo shutdown -r now
Note that the sudo command is used to run the shutdown command with administrative privileges, as shutting down the system requires elevated permissions.