Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the shutdown and restart commands in the Linux system

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

The purpose of this article is to share with you about the shutdown and restart commands in the Linux system. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.

Shutdown

Shutdown shuts down the system in a secure way. All login users will see a shutdown message, and login (1) will be blocked. You can specify to shut down immediately, or you can specify that the system shuts down after a certain delay. All processes will receive SIGTERM signals. This allows programs such as vi (1) to have time to store edited files, mail and news processes to properly clear data from all buffer pools, and so on. Shutdown does this by notifying the init process to change the runlevel. Runlevel 0 is used to shut down the system, runlevel 6 is used to restart the system, and runlevel 1 is used to put the system into the state of performing system management tasks, which is the default working state of the shutdown command if the-h or-r flag is not given. For specific shutdown or restart operations, please refer to the appropriate runlevel bar in the / etc/inittab file.

Option OPTIONS

-a

Use / etc/shutdown.allow to authenticate.

-t sec

The init (8) is notified to send a warning (warning) signal with a delay (sec) of a number of seconds before transmitting a kill signal before switching to another operating level.

-k

It is not really turned off, only a warning message is displayed to everyone.

-r

Restart.

-h

Stop the machine.

-n

[DEPRECATED (should no longer be used)] do not call the init (8) program for shutdown operation, but by yourself. Users are not recommended to use this shutdown method, and its results are generally not what you want.

-f

Skip disk detection on reboot.

-F

Force disk detection on restart.

-c

Cancel the running shutdown process. It is not possible to specify the time parameter for this option, but you can enter an explanation message on the command line to explain to all users. (general shutdown instructions can be interrupted by pressing the "+" sign.)

Time

Shutdown time.

Warning-message

Messages sent to all users.

The format of the time parameter can be varied. First, it can be absolute time in hh:mm format, where hh refers to hours (one to two digits) and mm refers to minutes (two digits). The second is the + m format, where m refers to the number of minutes to wait. Now is an alias for + 0.

If shutdown uses a delay when calling, it will automatically create an advisory file / etc/nologin to prevent login (1) from allowing new users to log in unless shutdown aborts unexpectedly before signaling init (that is, it is cancelled or something goes wrong). It deletes the file before calling init to change the run level.

-f

The flag means' quick restart'. This will create an advisory file / fastboot that will be detected when the system is rebooted. The startup script rc detects the existence of such a file, and if so, fsck (1) is no longer run because the system shuts down normally. After that, the startup process removes / fastboot.

-F

The flag means `force fsck'. This will create an advisory file / forcefsck that will be detected when the system is rebooted. The startup script rc detects the existence of the file, and if so, runs fsck (1) with a special `file flag so that even the normally unmounted file system is checked. After that, the startup process removes / forcefsck.

The-n flag causes shutdown not to call the init program to shut down, but to shut down all running processes. Shutdown then turns off quotas (quota), accounting (accounting), and swap partitions, unmounting all file systems.

Example:

The code is as follows:

[root@linux] # shutdown-h now # shutdown

[root@linux] # shutdown-h 23:00 # shutdown at 11:00

[root@linux ~] # shutdown-r now # restart

[root@linux ~] # shutdown-r + 30 'reboot now' # restart after 30 minutes and prompt reboot now

Halt

Mode of use:

Halt [- n] [- w] [- d] [- f] [- I] [- p] states that if the runlevel of the system is 0 or 6, shut down the system, otherwise replace it with the shutdown instruction (plus the-h parameter)

Parameters:

-n: do not write the memory data back to the hard disk before shutting down

-W: it doesn't really turn off, just write the record in / var/log/wtmp file.

-d: do not write records to / var/log/wtmp file (- n this parameter contains-d)-f: force shutdown, do not call the command shutdown

-I: stop all network-related devices before shutting down

-p: turn off the power supply (poweroff) by the way when you turn it off

Example:

The code is as follows:

[root@ubuntu ~] # halt # shutdown

Reboot

Function description: restart.

Grammar: dreboot [- dfinw]

Additional note: execute the reboot instruction to stop the system and restart the system.

Parameters:

-d No data is written to the record file / var/tmp/wtmp when rebooting. This parameter has the effect of the "- n" parameter.

-f force reboot without invoking the function of the shutdown instruction.

-I close all web interfaces before rebooting.

-n do not check for unfinished programs before rebooting.

-w only does the testing, does not really reboot the system, but only writes the rebooted data to the wtmp record file in the / var/log directory.

Example:

The code is as follows:

[root@ubuntu ~] # reboot # restart

The above are the shutdown and restart commands in the Linux system, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report