Several commands related to Linux shutdown and restart

Source: Internet
Author: User

1. Sync

Sync:flush file system buffers.

Sync command: Refreshes the file system's cache and writes data to the hard disk synchronously.

The need to perform the sync command: in the computer, the data processed by the CPU is first read into memory, which is often written back to the hard disk, but the speed of the hard disk is too slow relative to the memory, if the data is frequently exchanged between the memory and the hard disk, the system performance will be greatly compromised. So in order to speed up the data read speed, by default, some already loaded in memory of the data will not be directly written back to the hard disk, but the first temporary memory, then if the shutdown or restart the computer, the temporary memory of the data will probably be lost, the correct practice is to perform the sync command first, more than a few times, To ensure that data is written to the hard disk, in fact some shutdown commands perform a sync operation by default.

2, Shutdown

Shutdown:bring the system down.

The syntax format is as follows:
shutdown [OPTIONS] ... Time [MESSAGE]

Several parameters--
-K: Instead of a real shutdown, a warning message is sent, and no sign-in is allowed at this time.
-C: Cancels the shutdown instruction already in progress, the time parameter does not have to select, the message is the first parameter, this parameter is optional.
-R: Reboot the system service after it has been shut down.
-H: Halt or Powweroff after the system service is stopped.
-H: Halt after shutting down the system service.
-P: Poweroff after shutting down the system service.
Note : The time of the shutdown command is a required parameter, there are several formats, now means that immediately executes the same as the parameter is 0, the shape of 20:20 indicates the specific timing of the command execution, the shape of 20 for 20 minutes after the execution of the command.

3, reboot, Halt, Poweroff

The syntax format is as follows:
Reboot [OPTIONS] ... [Rebootcommand]
Halt [OPTIONS] ...
Poweroff [OPTIONS] ...

Reboot (8), Halt (8), Poweroff (8): Reboot or stop the system, these three commands are similar, they are in the same page8 when they look for man. When the command is executed with the parameter "-F" or the runlevel in 0~6, the system call reboot (2) (the Rebootcommand parameter will pass through) is activated and the system is restarted, otherwise the call is shutdown (8). The Rebootcommand parameter does not pass through at this time. Before calling reboot (2), the shutdown time record is written to/var/log/wtmp first.

Several parameters--
-F: With the above description, shutdown (8) is not called.
-P: Specified as the halt command, the effect is the same as Poweroff.
-W: Do Not call shutdown (8) and reboot (2), just write the shutdown time record to/var/log/wtmp.
–verbose: Output verbose command execution information.

4. Init

Linux has a total of seven execution levels, that is, the run level from 0 to 6, where run degree 0 means shutdown, run level 6 means reboot, the command to switch run level is init, as follows:

$ 0$ 6

Init 0 can be turned off and Init 6 can be restarted.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Several commands related to Linux shutdown and restart

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.