HowTo : Reboot Linux Server Command Line And Remotely

linux reboot server

Linux reboot Command

In linux system administration, it is sometimes required to restart our server after the completion of some network and other major updates either relevant to software or hardware that are being carried on the server. The reboot is needed so that the changes that we have done can be affected on the server. For example, if we are re-compiling the server’s kernel that undergoes some more advanced server administration, we have to restart the machine in order to complete the compilation and have a new updated kernel version on the server. Updating server’s memory, IP allocation, NIC configuration are the key tasks that need to have server restarted once leading to their successful implementation.

Most of the Linux system administrators do access the servers via shell or SSH to perform administrative activities, server management and monitoring. So they need to know the basic commands to restart the server from shell.

This article covers various restart commands and options such as

1. Where to find help regarding restarting your system.
2. How to restart your system.
3. How to schedule/cancel a restart.
4. How to remotely restart your server.
5. Restart with Init Command.
6. Checking reboot logs.

Where to find help?

Although this article is an effort to help you out but system documentation regarding each and every command in Linux can be found in man pages related to commands. There are various options available to restart system properly and you can read and inquire about each in a related man pages.

man reboot
man shutdown

How to restart your system

If all you need is a restart without going into details just help yourself with one of the following commands:

#sudo reboot
#sudo shutdown –r now

Note: usage of reboot, halt and poweroff is similar in syntax and effect. Run each command with –help to see the details.

Scheduled Restart

Simple reboot command has limited usage. Shutdown command is used instead of reboot for much more advance reboot and shutdown requirements. One such situation is a scheduled restart. Following is the syntax used to reboot your system after time defines by TIME.

#sudo shutdown –r [TIME] [MESSAGE]

Here TIME has various formats. Simplest one is “now”, already listed in previous section, and tells system to restart immediately. Other valid formats are +m, where m is the number of minutes to wait until restart and HH:MM which specifies the TIME in 24hr clock. Below are the examples and their outputs. Optional MESSAGE argument can be use to intimate users prior to reboot to prevent possible loss of data.

Example 1: Reboot your system after 5 minutes

#sudo shutdown –r +5
Broadcast message from [email protected]
(/dev/pts/1) at 20:49 ...
The system is going down for reboot in 5 minutes!

Example 2: Reboot your system after 02:00 A.M.

#sudo shutdown –r 02:00
Broadcast message from [email protected]
(/dev/pts/1) at 20:51 ...
The system is going down for reboot in 309 minutes!

Canceling Restart

If you want your system to discard previously scheduled restart or shutdown you can call another shutdown command with –c option and broadcast with it a message for users about the cancelation of restart. Here is the syntax and example

#sudo shutdown –c [MESSAGE]

Example 3: Cancel Reboot

Previously scheduled reboot can be cancelled by system administrator by issuing another shutdown command with –c option and optional message argument.

#sudo shutdown –c “showing how to cancel scheduled reboot ”
Broadcast message from [email protected]
(/dev/pts/1) at 20:59 ...
showing how to cancel scheduled reboot

Restart remote server

Simply login your server with any ssh client using server authentication information and issue any of the following commands:

$ ssh [email protected] /sbin/reboot
$ ssh [email protected] /sbin/shutdown –r now

Restart with Init Command

Init is taken from the word initialize that is widely used to initialize/start different processes in a linux server, so this command used as a joint with runlevel 6; a number which is set for rebooting a linux server leads to get the server rebooted. The syntax is mentioned below:

[[email protected] ~]# init 6
[[email protected] ~]# /sbin/init 6

Checking reboot logs

/var/log/wtmp file records all logins and logouts. One can parse this file with last command in order to access log for reboot. Below is the last command usage and its output on my system.

#last reboot
reboot system boot 3.2.0-32-generic Sun Nov 4 11:00 - 22:11 (11:11)
reboot system boot 3.2.0-32-generic Sat Nov 3 20:02 - 02:10 (06:08)
reboot system boot 3.2.0-32-generic Sat Nov 3 17:52 - 18:56 (01:03)
reboot system boot 3.2.0-32-generic Sat Nov 3 15:37 - 17:32 (01:55)
reboot system boot 3.2.0-32-generic Sat Nov 3 11:00 - 11:02 (00:01)
reboot system boot 3.2.0-32-generic Sat Nov 3 10:25 - 10:58 (00:32)
reboot system boot 3.2.0-32-generic Fri Nov 2 20:21 - 23:25 (03:04)
reboot system boot 3.2.0-32-generic Fri Nov 2 16:57 - 18:54 (01:56)
reboot system boot 3.2.0-32-generic Fri Nov 2 15:22 - 16:35 (01:13)
reboot system boot 3.2.0-32-generic Fri Nov 2 12:51 - 13:37 (00:46)
reboot system boot 3.2.0-32-generic Thu Nov 1 20:04 - 23:55 (03:50)
reboot system boot 3.2.0-32-generic Thu Nov 1 15:18 - 23:55 (08:36)
reboot system boot 3.2.0-32-generic Thu Nov 1 11:42 - 13:59 (02:16)

wtmp begins Thu Nov 1 11:31:44 2012

Bobbin Zachariah 12:57 pm

About Bobbin Zachariah

Founder of LinOxide, passionate lover of Linux and technology writer. Started his career in Linux / Opensource from 2000. Love traveling, blogging and listening music. Reach Bobbin Zachariah about me page and google plus page.

Author Archive Page

Have anything to say?

Your email address will not be published. Required fields are marked *

All comments are subject to moderation.