How to modify the Linux runlevel value

  

First, what is initinit is one of the indispensable programs in Linux system operation. Is a user-level process initiated by the kernel. After the kernel is booted (has been loaded into memory, started running, and all device drivers and data structures have been initialized, etc.), other user-level processes or services are started by initiating a user-level program init. Therefore, init is always the first process (its PID is always 1). The kernel will look it up in a few places where init has been used in the past, and its correct location (for Linux systems) is /sbin/init. If the kernel can't find init, it will try to run /bin/sh. If the run fails, the system will fail to start. Second, the run level Run level is the operating level of the operating system
is currently running. This level ranges from 1 to 6 and has different functions. The functional levels are as follows: # 0 - Shutdown (do not set initdefault to 0) # 1 - Single User Mode # 2 - Multi-user, no NFS # 3 - Full Multi-User Mode (Standard Run Level) # 4 - No Use # 5 - X11 (xwindow) # 6 - Restart (do not set initdefault to 6— — set the initdefault of your blacked out linux to 0 or 6 as a denial of service attack!) There are also three ABC running levels, but there is no point in RHLinux. These levels are specified in the /etc/inittab file. This file is the main file that the init program looks for. The first service to run is the file placed in the /etc/rc.d directory. In most Linux distributions, the startup scripts are located in /etc/rc.d/init.d. These scripts are connected to the /etc/rc.d/rcn.d directory with the ln command. (The n here is the run level 0-6.) 3. The runlevel configuration Runlevel configuration is done in the /etc/inittab line as follows: 12 : 2 : wait : /etc /init.d /rc 2 The fields are explained as follows: id:runlevels:action:processid: is an arbitrarily specified sequence of four characters, which must be unique within this file; use the old version of libc5 (below 5.2.18) or a.out library The compiled sysvinit is limited to 2 characters. Note: Login processes like getty must match the id field with the tty number. For example, tty1 requires id=1, and many older versions of the login process follow this rule. Runlevels: indicates that this line is suitable for running that level (here is 2, there can be more than one, indicating that it needs to run at the corresponding run level); in addition, the three processes sysinit, boot, and bootwait will ignore this setting. Action: indicates the way init should run the command of the process field when entering the corresponding runlevels. Common field values ​​and explanations are in the appendix. The wait in the example means that the process needs to be run once and wait for it to end. Process: The specific command that should be executed. The /etc/init.d/rc command in the example starts the process/command that should be run in runlevel 2 and is responsible for terminating it when exiting the runlevel (except of the programs that are still running in the incoming runlevel.) The run level changes, and the running program does not specify the need to run in the new run level, then init will first send a SIGTERM signal to terminate, then SIGKILL. The valid action values ​​are as follows: respawn: indicates that init should monitor this process, even if it is finished, it should be restarted. Wait: init should run this process once and wait for it to finish before proceeding to the next step. Once: init needs to run this process once. Boot: Runs with the system, so the runlevel value is invalid. Bootwait: Runs with the system and init should wait for it to end. Off: No meaning. Initdefault: The default runlevel after the system is started. Because the corresponding runlevel is activated, the corresponding process is activated, so there is no meaning for specifying the process field. If this record does not exist in the inittab file, the system will ask for the entry level on the console when it starts. Sysinit: The command to be run when the system starts. For example, this command will clear /tmp. You can look at the /etc/rc.d/rc.sysinit script to see what it is running. Powerwait: Allows init to shut down the system when the power is turned off. Of course, the premise is that there is U P S and software that monitors U P S and informs init that the power has been cut off. RH linux does not list this option by default. Powerfail: Same as powerwait, but init does not wait for the running process to end. RH linux does not list this option by default. Powerokwait: The operation that init is to perform when the power monitoring software reports "power recovery". Powerfailnow: The operation that init is to perform when it detects that the ups power is about to run out, which is different from powerwait/powerfail. Ctrlaltdel: Allows init to restart the system when the user presses C t r l + A l t + D el on the console keyboard. Note that if the system is placed in a public place, the system administrator can configure the Ctrl + Alt + Del key combination for other behaviors, such as ignoring. I am set to print a swearing word ^o^. Kbrequest: It is not perfect to monitor the action taken when a particular keyboard combination is pressed. Ondemand:A process marked with an ondemand runlevel will beexecuted whenever the specified ondemand runlevel is called. However, no runlevel change will occur (ondemand runlevels are ‘a’, ‘b’,and‘c’), (English too , that however, I don't know how to translate. 惭愧!) Added: 1. About entering single-user mode, generally set the initdefault to 1 or specify a “single” or “emergency” command in grub/lilo. Line parameters are implemented. In fact, there is a cleaner way, edit: kernel /vmlinuz-2.6.9-22.EL ro root=/bin/sh, so init will start a shell directly, no other process is started, it is clean enough ! 2, you can make your own runlevel into the startup, if your system is using lilo, the corresponding part in the startup command is: LILO: linux 5 If you are using GRUB, you can press and hold at startup The e key enters the setting mode, and the corresponding position is displayed as: kernel /vmlinuz ro root=/dev/hda1 53. When the system is running, the telinit (or init) command can change the running level. Switch the operating mode using the telinit command (root user): $ /sbin/telinit Normally, the purpose of switching the running mode is to restart some application processes, such as XFree86, switching the operating mode from 5 to 3 will terminate XFree86 and all related to it. Process, and then switch the run mode to 5, XFree86 can be started very cleanly. Before doing this work, please make sure that all work under XFree86 has been saved, use root user: $ /sbin/telinit 3$ /sbin/telinit 5 After typing the command, your screen may show some services to start or stop. Information.

Copyright © Windows knowledge All Rights Reserved