Ubuntu shutdown, restart and logout commands

To learn the linux system , the most important thing is to use various commands to operate the system and open various software. This time, we mainly analyze the detailed explanation of the shutdown, restart, and logout commands in ubuntu.

Shutdown command shutdown

1) Use shutdown --help to view how to use the shutdown command, of course, you can also use the man shutdown command.

$shutdown –help command, check the help manual, which briefly introduces the use of the shutdown command.

$man shutdown command, which shows the usage of shutdown command in detail.

Some screenshots are omitted here, and you can check the man manual for details.

Detailed explanation of the Shutdown command:

1) shutdown -h now shutdown now immediately

2) shutdown -r now restart immediately now

3) shutdown -r +3 restart after three minutes

4) shutdown -h +3 "The System will shutdown after 3 minutes" prompts the user to shut down after three minutes

5) shutdown -r 21:00 will restart the computer at 21:00

6) shutdown -r 20:30 & can put the task restarted at 20:30 in the background, and the user can continue to operate the terminal

2 interrupt command

1) After the command is executed (if it is not transferred to the background), you can use CTRL+C to abort the command

2) kill program code

When the command is executed in the background, the system will return a program code, for example: when using shutdown -r 20:23 & the system returns the system code: 4905

We can use kill 4905 to abort the restart command

3ps aux | grep program number

If we know the program number, we can use ps aux |grep program number to query what the command corresponding to the program number is.

For example, the above program number is 4905, we can use ps aux | grep 4905 to find the shutdown -r 20:23 & command

halt - the simplest shutdown command

In fact, halt is to call 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.

Parameter Description:

[-n] Prevent the sync system call, which is used after patching the root partition with fsck to prevent the kernel from overwriting the patched superblock with the old version of the superblock (superblock).

[-w] is not a real restart or shutdown, but just write wtmp [/var/log/wtmp] records.

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

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

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

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

init

init is the ancestor of all processes, and its process number is always 1, so sending a TERM signal to init will terminate all user processes, daemon processes, etc. shutdown uses this mechanism. init defines 8 runlevels (runlevel), init 0 is shutdown, and init 1 is restart. There can be a long story about init, so I won't describe it here. In addition, there is a telinit command that can change the running level of init. For example, telinit -iS can make the system enter single-user mode, and the information and waiting time when using shutdown cannot be obtained.

logout command to log out of the system

Logout Logout is the relative operation of login. After logging in to the system, if you want to leave the system, the user only needs to issue the logout command directly:

This test uses xshell to remotely access its own ubuntu system.

Note: The logout command can only be used in the command line mode. If it is under the graphical desktop of ubuntu, you can only use the options in the graphical interface to log out.

Friends who are interested in the embedded Internet of Things can learn more about relevant information. (look over)

Guess you like

Origin blog.csdn.net/m0_70888041/article/details/130820030