Linux command shutdown restart command usage summary

  

Today Xiaobian introduces you to the Linux system shutdown and restart commands, the commands involved are shutdown, halt, reboot, is also the main explanation of this article, I hope to learn friends Helpful.

a, shutdown command

In linux operating system, shutdown is the shutdown command.

When you execute this command, you need to bring some parameters, such as: shutdown -h now command to shut down immediately.

However, when running such a command on the terminal, Linux sometimes does not shut down. This is not only a problem for the root user. To switch the user to root, use su - root to enter the password before running. Shutdown -h now, then linux can be shut down.

Problem:

The Linux shutdown command is invalid. The prompt is returned: command not found.

The reason is that ordinary users do not have the right to shut down, they must call the administrator user.

Although the root user is still using the shutdown shutdown command.

Therefore, you must use the su command in the shell to call up the root user and then execute the Linux shutdown command.

Example of operation:

Example of copy code code: su - root

password

shutdown -h now

Code Description:< Br>

The first line, - there is a space before and after.

The second line is the password of the system root user. If you are currently using a non-root user, you will be asked to enter it; if you are currently using the root user, you do not need to enter it and enter the next line of commands directly.

The third line, the code followed by shutdown refers to the relevant explanation document.

shutdown Shut down the computer, send a signal to the root process init, change the runlevel to 0 (halt)

-h turn off the power

-r restart

- n Forced shutdown, do not send signals to the init process

-k Simulate shutdown, send shutdown warning to the registrant

-t "seconds" shutdown after N seconds eg:-t 60 //60 Shutdown after seconds

time "Time" Timed shutdown

-c [Description] Cancel shutdown

-f Ignore detection file system on reboot

- F Force detection of file system when restarting

Second, halt shutdown command, this command is a simple shutdown command

halt command, which can be equivalent to calling shutdown -h.

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.

Parameters for the halt command:

[-n] Prevents the sync system call. It is used to fix the root partition with fsck to prevent the kernel from overwriting with the old version of the superblock. A patched super block.

[-w] It's not really a reboot or shutdown, just write a wtmp[/var/log/wtmp] record.

[-d] Do not write wtmp records [included in option [-n]].

[-f] Force shutdown or restart without calling shutdown.

[-i] Turn off all network interfaces before shutting down (or restarting).

[-p] This option is the default option. It is to call poweroff when shutting down.

Third, reboot command

The function of this command is: reboot. Now that it is rebooted, there will of course be a process of shutting down and restarting. This is not difficult to understand.

Note: This command is also available under Windows.

Name: reboot

Permissions: System Manager

Note: Executing the reboot command will stop the system and reboot.

Usage: reboot [-n] [-w] [-d] [-f] [-i]

Description: If the system's runlevel is 0 or 6, then reboot Otherwise, replace the

with the shutdown command (plus the -r parameter). Parameter:

-n : Do not write the memory data back to the hard disk before rebooting

-w : does not really reboot, just write the record to the /var/log/wtmp file

-d : Do not write the record to the /var/log/wtmp file (- n This parameter contains -d) -f : Forced reboot, do not call shutdown.

-i : Stop all network-related devices before rebooting

Example:

Copy code code example: reboot reboot.

reboot -w Reboot simulation, this operation only records, but does not really reboot.

The above is the introduction of the Linux system shutdown and restart command. It does not necessarily shut down and restart when the terminal is running. Adding different parameters will have different effects. Try it.

Copyright © Windows knowledge All Rights Reserved