Four shutdown and restart of common command skills under UNIX platform

xiaoxiao2021-03-06  62

Four shutdown and restart of common command skills under UNIX platform

Li Shouliang SLLI@founder.com.cn

Lastversion: 2003-03-04

Brief description

In configuring the system kernel, there is a hardware problem, the system is unable to return, and the system performance is serious, power failure, server movement, etc. need to be turned off or restarted to the server. You need to boot to single user mode when you install some system-level patches.

When UNIX is started, the following tasks are launched by init according to the run level, including multi-user environment, network, etc. The run level is the functional level of the operating system is currently running. Each level has a different function. These levels are specified in the / etc / inittab file. This file is the main file of the init program, the first service running is those files placed in the /etc/rc#.d directory.

table of Contents

First, run the control directory

Second, the operating level definition of init

Third, several related orders introduction

1, shutdown command

2, halt command

3, poweroff command

4, reboot command

Fourth, recommend several security shutdown methods

content

First, run the control directory

/etc/rc0.d is used to stop the script of the system

/etc/rc1.d Script for single-user or maintenance mode

/etc/rc2.d into multi-user mode scripts

/etc/rc3.d Start the script of the remote file sharing multi-user mode

/etc/rc4.d Enter the system maintenance mode script provided by the manufacturer

/etc/rc5.d system is useless, you can have user-defined

/etc/rc6.d reboot system script

The main function of running the control script is to perform scripts used to violate the start-level launch service. For example, when the system boots, the management process reads the / etc / inittab file. This file tells the system that the current default run level is 3, the process sequence executes / ET / RC0, / ETC / RC1, / ETC / RC2, then executed / ETC / RC3 ends. If the system is retracted to run level 2, the / etc / rc6, / etc / rc0, / etc / rc1, and the execution / etc / rc2 ends sequentially.

The default run level in the / etc / inittab can change. If you change, you can use the init Q to immediately retrieve the processing / etc / inittab file immediately. But don't set the default level to 1, 5 and 6.

Second, the operating level definition of init

0 Close the operating system to turn off the power

1 single user maintenance status

2 Multi-user status of normal operation, all management processes other than NFS Server and Syslog are running

3 Multi-user status of normal operation, the system starts default enters this state

More than 4 user status (no need now)

5 Turn off the operating system to turn off the power supply, if the system is supported, you can automatically cut off the power

6 Turn off the operating system and restart

S or S single user status (some system is started)

# init 0

The system starts the RC0 script to kill the running process, turn off the operating system to the OK status, at which time manual intervention is required, it is a power off shut down or execute boot reboot.

# init 1

The system kills the running process to start to single user mode. Need manual intervention

Ctrl D enters the normal start mode, or enter the root password to enter the maintenance mode. After performing the operation, use Ctrl D to switch to multi-user mode.

# init 5

After the system kills the running process, turn off the operating system if the system is supported, automatically power off.

# init 6

Run the script to kill the process, restart three, and several related commands

1, shutdown command

All UNIX operating systems have this command that allows the system Shutdown, PowerOff or Reboot. This command is a better command to turn off the operating system. Only super users have run permissions. Run this command is typically at the console terminal. When this command is executed remotely, the shutdown message section is displayed on the remote machine, and the console terminal can receive all the error messages during the shutdown process and display the truly closed state. Have to use init 5 when shutdown remotely.

Shutdown has the following advantages:

1) Command can specify the time parameter to send messages to the user in use, prompt to exit safely within the parameter time;

2) Then run the 0-level KILL to remove any processes left;

3) Confirm whether the update of the file system has been written, run the SYNC command to refresh the disk block of all reality memory, then uninstall the file system

4) Finally call the HALT command to enter the shutdown mode

Example:

#SHUTDOWN -Y -G300 -I0

The system prompts all users to shut down after 300 seconds, and then run 0 running levels into the OK state, hand-on whether manual intervention is powered down or boot. If you don't want to use Shutdown -Y G0 -I0 or SHUHTDOWN -I0 NOW

#SHUTDOWN -Y -G0 -I5

If you want to shut down the operating system immediately and power down to execute Shutdown -y -G0 -i5, because -i0 needs manual power-off.

In addition, on AIX, run the shutdown command from any run level, the system automatically powers, and requires the power switch or reset button on the manual operating host.

# Shutdown or shutdown 1-h or shutdown -g0 -y

Return to Level: s, use Ctrl D (0 ~ 6) to run the level, default is 3

Runtime 5 is usually powered by the computer after the operating system is stopped.

2, halt command

The HALT command only completes a part of the shutdown process. He does not report the user who is logging in. Do not perform KILL operation, and immediately uses #halt -q will stop the system immediately, no synchronization, no kill process or write log ,very dangerous.

3, poweroff command

The poweroff command does not report the user who is logging in and does not perform the KILL script operation, and immediately shutddown and powered down. If securely use this command, you should use the synchronization command SYNC. Refresh all of the disk blocks that keep memory, and then power down.

Example:

#Sync; Sync; Poweroff

4, reboot command

The reboot command immediately executes Shutdown and retains the system to Level 3 mode, and the difference between INIT 6 is not running the RC0 KILL script without notifying the Logged user. Safe use should be used with the synchronization command.

Example:

#Sync; Sync; Reboot

Fourth, recommend several security shutdown methods

1. Use it in the console terminal, immediately turn off the operating system and power out

#SHUTDOWN -Y -I5 -G0

The parameters of -G0 can be used to quit the given, the unit is second, and the equivalent command is:

#SHUTDOWN -Y -I5 Now

See above with the benefits of Shutdown.

2, use it in the console terminal, immediately turn off the operating system, hand-off or boot

#SHUTDOWN -Y -I0 -G0

If SHUDOWN does not end, you need to run

#ininit 0

3, remote shutdown, shut down the operating system and power off to shut down remotely, you can also use init 5, example

# init 5

It is said that sometimes INIT 5 will cause the machine to hang, so you can choose to use it when you have to shut down remotely.

4, # sync; sync; poeroff

Confirm that some important services have stopped, such as Oracle, WebLogic, etc., refreshed all the retention memory (two execution synchronization command SYNC), making power outages. This command is shut down quickly, and after synchronization, it is also safe. You can choose to use.

5, AIX system uses shutdown commands, manual power-off

6, restart

When the internal verification or other needs to restart the server, it is recommended to use the following command:

# init 6

or

# sync; sync; reboot

In short, the Sun system recommends the shutdown command to #SHUTDOWN -Y -I5 -G0

Li Shouliang SLLI@founder.com.cn

2003-03-04

转载请注明原文地址:https://www.9cbs.com/read-106527.html

New Post(0)