Home > php教程 > PHP开发 > body text

All linux shutdown commands

高洛峰
Release: 2016-12-17 16:30:38
Original
1446 people have browsed it

1. shutdown

The shutdown command is the most commonly used command to shut down the system. It can not only be used to shut down the system immediately, but also shut down the system at a specified time.

Using the shutdown command, the system administrator will notify all logged in users that the system will be shut down.

The login command is frozen and new users can no longer log in. It is possible to shut down directly or delay the shutdown for a certain period of time, and it is also possible to restart.

This is determined by all processes receiving signals sent by the system.

This gives programs like vi time to save the document being edited, and programs like email and news can exit normally.

shutdown sends a signal to the init program, asking it to change the runlevel.

Runlevel 0 is used to shut down [halt]﹐runlevel 6 is used to reactivate [reboot] the system﹐

runlevel 1 is used to put the system into a state where management work can be carried out; this is the default, assuming there is no -h There is no -r parameter to shutdown.

If you want to know what actions were taken during the shutdown (halt) or restart (reboot) process﹐

you can see the runlevels related information in the file /etc/inittab.

(1) Shut down the system after 1 minute: # shutdown -h 1

Since shutting down and restarting the system requires administrator privileges, shutdown and restart system commands such as shutdown should be executed as the root user.

Shut down the system immediately: # shutdown -h now

(2) Shut down the system at a specified time: # shutdown -h 15:30

When the root user issues a shutdown command, other users in the system can get the following prompt:

The system is going DOWN for system halt in 2 minutes!

If you get this prompt message, the user should immediately stop the ongoing job, save the necessary data and exit the system.

(3) The shutdown command can also be used to restart the system: # shutdown -r 2

The system will restart in 2 minutes.

If there is more than one user using the system, you should use the shutdown command when shutting down the system,

and use a delayed shutdown method to avoid data loss.

2. halt


The halt command is used to suspend the system (suspending the system is usually used in portable devices such as notebooks).

Unlike the shutdown and poweroff commands, using halt will only suspend the system (the system stops operation) without cutting off the host power.

Use halt to suspend the system immediately: # halt

Note: Since suspending the system requires the support of multiple hardware drivers, you should make corresponding settings in the system before using suspend.

Otherwise, the system may not be able to be restored. Phenomenon.

When Halt is executed, the application process is killed, the sync system call is executed, and the kernel is stopped after the file system write operation is completed.

3. Reboot

When restarting the system, if you are sure that there is no user data that needs to be saved in the system, you can use the reboot command.

Use the reboot command to restart the system: # reboot

After using the reboot command, the system will immediately shut down and restart

4, init


init is the ancestor of all processes, its process number is always 1﹐ Sending the TERM signal to init will terminate all user processes, daemon processes, etc.

The run level is very important in the Linux system. It describes the running status of the Linux system and is also an indispensable part of Linux system management knowledge. The Linux system uses numbers 0 to 6 to represent the system running status (i.e., run level). The seven run levels are as follows.

0: The number 0 means shutdown. When the run level is switched to 0, the system will immediately shut down the running services and power off the system.

1: The number 1 represents single-user mode, which is similar to the safe mode in Windows systems.

When the system’s run level is switched to 1, the system only allows root users to log in. Single-user mode is generally used for system maintenance.

2: Multi-user mode, when the system is in run level 2, users cannot use NFS (Network File System).

Under operating level 2, the system will refuse to provide services to other computers in the network. This mode is generally used for system maintenance.

3: Full multi-user mode: Full multi-user mode is the run level where the Linux system works normally in command line mode.

Many servers currently use this run level.

4: Not allocated for use. This level is mainly used by developers to customize its functions. It is currently mainly used for the development and application of microcontrollers or other systems (such as mobile operating systems).

5: Graphics mode. This run level is basically the same as run level 3. The difference is that in this mode, users will use the graphical interface to log in and use the Linux system.

6: Restart. The system will restart immediately at this run level.记 Skill: If you forget the root user password, you can switch the system's running level to a single user mode when the system starts, and then reset the root user password.

Use the init command to shut down the system immediately: # init 0

Use the init command to restart the system immediately: # init 6

When using the init command, the system will immediately perform a switching operation, so you should first check whether other users are using the system.

5. poweroff


If you confirm that there are no users in the system and all data has been saved, and you need to shut down the system immediately, you can use the poweroff command.

Use poweroff to shut down the system immediately: #poweroff


means to cut off the power directly. In a system without power management, there is no difference between the two.


And if there is a power management system, halt just suspends all instructions. Computing, system stop, more at the software level,


poweroff is to send an ACPI power cutoff command to the power supply system to stop the power supply, mainly at the hardware level



more linux shutdown commands For related articles, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template