Introduction

There’s a reason that tech support asks you if you’ve rebooted your computer. It’s cliched but true – restarting a computer solves a wide variety of issues.

When a system is rebooted, any malfunctioning software is purged from active memory.  When the system restarts, it loads a fresh, clean copy of the software into active memory. Also, some operating systems require a restart to process updates or configuration changes.

Most GUI (graphical user interface) operating systems have a click-menu for shutting down or restarting. But sometimes a graphical interface malfunctions, or you might only have access to a command line.

This guide will help you restart a Linux server using only the command line or prompt.

Prerequisites

  • A computer running a Linux operating system
  • Access to a command line interface (also known as a terminal)
  • Root or sudo privileges
  • Save any work or applications that are running!

Tools/Software

  • (optional) SSH software package for communicating with a remote server (see Part B)

Steps To Restarting Linux Using Command Prompt

Part A: Restarting a local Linux operating system

Step 1: Open a terminal window

If your version of Linux uses a graphical interface, you can usually open a terminal window by right-clicking the desktop > left-clicking Open in terminal.

Alternately, you can click the main menu (usually found in the lower-left or upper-left corner), and then click Applications > System Tools > Terminal.  (Your process may vary.  If you have it, you can also use the search function.)

Step 2: Use the shutdown command

Since powering off is one of the most basic functions of an operating system, this command should work for most distributions of Linux.

In the terminal, type:

sudo shutdown –r

The sudocommand tells Linux to run the command as an administrator, so you may need to type your password.  The –rswitch on the end indicates that you want the machine to restart.

NOTE

If you leave the -r switch off, your system will only shut down. You’ll need to manually power back up.

Step 3: Other shutdown commands

You can use the shutdowncommand with different switches to control its behavior.

To shut down completely, right now:

sudo shutdown –h now

To tell your computer to reboot in 30 minutes:

sudo shutdown -r +30

You can also tell your system to reboot at a certain time:

sudo shutdown –r 16:45

NOTE

Use the 24-hour format to enter your desired time.

Step 4: An easier way to restart

In the terminal, type:

reboot

Many Linux versions do not require administrator privileges to reboot.  If you get a message that you don’t have sufficient privileges, type:

sudo reboot

Your system should close out of all open applications and restart.

Part B: Reboot a remote Linux server

Step 1: Open a command prompt (see above)

Step 2: Use an SSH connection to issue a reboot command

In a terminal window, type:

ssh –t user@server.com ‘sudo reboot’

Note:  You may need to enter the password for the username you’ve used.  Also, make sure you type the single-quote marks.

The ssh command tells your system to connect to another machine.  The –t option forces the remote system to enter the command in a terminal.  Replace user@server.com with the username @ server name that you want to restart.

The ‘sudo reboot’ command can be switched out for ‘sudo shutdown’  and the above options above can be used. (That is:  -r tells it to restart, hh:mm sets a specific time, +mm sets a countdown.)

Conclusion

In this tutorial, you learned how to restart a Linux server from the command prompt.

Rebooting a Linux system or server is designed to be simple, so you shouldn’t have any trouble.  Make sure you’ve saved all your work before you hit enter!