How to Restart or Shutdown Ubuntu from Terminal Command Line

How to restart Ubuntu or shutdown Ubuntu from terminal command line immediately. In this tutorial we will learn about the shutdown command in Linux with examples to turn off Ubuntu using terminal.

Command 1 – reboot

The reboot command can be used to halt, poweroff or reboot the machine. The different reboot command options which can be used in terminal are:

  1. –halt : Halt the machine, regardless of which one of the three commands is invoked.
  2. -p, –poweroff : Power-off the machine, regardless of which one of the three commands is invoked.
  3. –reboot : Reboot the machine, regardless of which one of the three commands is invoked.
  4. -f, –force : Force immediate halt, power-off, reboot. Do not contact the init system.
  5. –no-wall : Do not send wall message before halt, power-off, reboot.

Command 2 – shutdown

The shutdown command can be used to halt, poweroff or reboot the machine.

When the command is executed the first argument may be a time string (which is usually “now”). Optionally, this may be followed by a wall message. It is the message which is meant to be sent to all logged-in users before the system is shutdown.

The time string may either be in the format “hh:mm” for hour/minutes specifying the time to execute the shutdown at, specified in 24h clock format.

NOTE: When the time argument is used, 5 minutes before the system goes down the /run/nologin file is created to ensure that further logins shall not be allowed.

Following are the different shutdown command options that can be used in terminal:

  1. -H, –halt : Halt the machine.
  2. -P, –poweroff : Power-off the machine (the default).
  3. -r, –reboot : Reboot the machine.
  4. -c : Cancel a pending shutdown. This may be used cancel the effect of an invocation of shutdown with a time argument that is not “+0” or “now”.

For example to shutdown after 10 minutes:

$ sudo shutdown -r 10

Command 2 – halt

The halt command can be used to halt, power-off or reboot the machine. On the UNIX based OS systems, the halt command has the following options:

  1. –halt : Halt the machine, regardless of which one of the three commands is invoked.
  2. -p, –poweroff : Power-off the machine, regardless of which one of the three commands is invoked.
  3. –reboot : Reboot the machine, regardless of which one of the three commands is invoked.
  4. -f, –force : Force immediate halt, power-off, reboot. Do not contact the init system.
  5. –no-wall : Do not send wall message before halt, power-off, reboot.

NOTE: Please be cautious before using any of the above given commands via Terminal.

You can also use sudo systemctl poweroff command to shutdown or power off an Ubuntu server desktop.

I hope you found this tutorial useful.

Author: Team Linux Ledger

The team of Linux experts and open source enthusiasts who are passionate about sharing their expertise with you through in-depth tutorials, news, and updates on various aspects of open source in general and Linux in particular A team that helps you become a better Linux user.

Leave a Comment