Linux system various reboot commands

Source: Internet
Author: User

While doing Linux system operations, if the replacement of hardware, change the system configuration and panic, and so on, you need to restart the computer, and the different circumstances to restart the way is different, that is, the use of different commands, the following small series to introduce under Linux under different circumstances of the restart method.

Unlike the desktop system, as a server, we are less likely to reboot the Linux system, but we will restart the machine when the following conditions are present:

Replacing hardware

Change System Configuration

System Zombie, reboot recovery required

Shutdown and restart system mode

The boot system is essentially only one method, and unlike this, there are several ways to shut down or reboot the system:

Power Off (down)

Using the Shutdown command

Using the halt, Poweroff, or reboot commands

Using Telinit to change the Init run level

Power off

For the following two reasons, directly to the machine under the electricity, is not a good habit:

may cause hardware corruption

Some of the data may still be in memory, not written back to the disk, at which time the power will lose data or file system damage;

So try to shut down or reboot the system in other ways as much as possible.

Shutdown command

Use shutdown to suspend (halt) or reboot (reboot) systems, use the-H option to indicate a suspend system, play the same role as the halt command, and use the-r option to indicate that the system is restarted with the same effect as the reboot command.

After the shutdown command is executed, the system sends a pending or restart message to all login users.

Send a pending message after executing shutdown–h now:

The code is as follows:

[SQL]

# shutdown-h Now]

Broadcast message from root (tty1) (Thu 3 10:58:22 2012):

The system is going down for system halt now!

Init:switching to Runlevel:0

Init:sending processes the TERM signal

Send a restart message after executing shutdown–r now:

The code is as follows:

[SQL]

# Shutdown-r Now

Broadcast message from root (tty1) (Thu 3 11:18:22 2012):

The system is going down for system reboot now!

Init:switching to Runlevel:6

Init:sending processes the TERM signal

After performing shutdown, other users can no longer log into the system, and we can specify the system suspend or restart time and instructions, as follows two cases:

Early morning 1::00 Downtime maintenance:

The code is as follows:

[SQL]

Shutdown–h 1:00 "Going down for scheduled maintenance. Expected downtime is 1 hour. "

Specifies that the shutdown is 15 minutes after the relative shutdown time:

The code is as follows:

[SQL] Shutdown–h +15 "Going down for emergency check."

Halt and Reboot command

Halt records shutdown, terminates non-essential processes, performs sync system calls, waits for file system write operations to complete, and then stops the kernel, Poweroff command equivalent to halt.

From the above "Shutdown–h" and "Shutdown–r" to perform the output know that the execution of halt that goes to run level 0, the execution of reboot that goes to run Level 6, log file/var/log/messages log the corresponding logs.

System reboot log:

The code is as follows:

[SQL] May 3 11:45:25 slot14 shutdown[11119]: Shutting down for system reboot

May 3 11:45:25 slot14 init:switching to Runlevel:6

May 3 11:45:25 slot14 user_cmd:2012-05-03 11:45:25 shutdown-r now by root from [root tty1 May 3 11:44]

System suspend log:

The code is as follows:

[SQL] May 3 10:50:22 slot14 shutdown[11561]: Shutting down for system halt

May 3 10:50:22 slot14 init:switching to runlevel:0

May 3 10:50:22 slot14 user_cmd:2012-05-03 10:50:22 shutdown-h now by root from [root tty1 May 3 10:48]

By looking at the/var/log/messages log records, you can determine whether the machine is restarted or artificially restarted.

Telinit command

The Execute telinit command directs init to the specified run level, such as restarting the system:

The code is as follows:

[SQL]

#telinit 6

When using Telinit, you do not get a friendly warning message like the execution of shutdown, less as a suspend and restart command, but a modified server for/etc/inittab files, which is a relatively large action. When operating system-related failures occur, we should first consider the collection of log information, if necessary, restart the system.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.