Linux Learning Note (iii): System execution level and execution level switching

Source: Internet
Author: User
Tags switches

The 1.Linux system differs from other operating systems, and it has an execution level. The execution level specifies the state in which the operating system is located. Linux systems are executed at an execution level at all times, and the programs and services performed at different execution levels are different, and the work to be done and the purpose to be achieved are different.


2.Linux (Red Hat 9.0) sets up 7 different execution levels, and the system is able to switch between these level of execution to complete different tasks.


3. Next, 7 system execution levels are introduced:

(1). Execution Level 0: Turn off the computer.

(2). Execution Level 1: Single user mode.

(3). Execution Level 2: Multi-user mode (without network File system NFS support feature).

(4). Execution Level 3: Multi-user mode with NFS support for network file systems.

(5). Execution Level 4: The System reserves the standby.

(6). Execution Level 5: For self-initiated XFREE86 system (graphical mode).

(7). Execution Level 6: Start again.

There are also two special levels of execution (execution level)


4. Next, understand the 7 system execution levels:

(1). Execution Level 0 is designed to shut down the computer system. At this point in the system all open services to stop, in the execution of the process is to transition to a state of termination, the system to recover the allocated resources, and power off the system.

When the shutdown Command shutdown-h command is used, the system is transferred to that execution level.

(2). Execution Level 1 is designed to maintain a computer system for entering single-user mode. At that execution level it is possible to perform some unsuitable in multi-user. Commands executed in multi-tasking mode. At this point the system only opens very few services.

(3). Execution Level 2, 3. 5 are multi-user mode. Only the execution level 2,3 is the character terminal mode, but the execution level 2 does not have network File System (NFS) support, and the execution level 3 with Network File System (NFS) support. Execution Level 5 is a graphical way, it makes ordinary user's operation easier and convenient.

(4). Execution Level 6 is designed to restart the computer system, the system is all open services to stop, in the execution of the process is to transition to a state of termination, the system to recover the allocated resources, and again start the computer system. When you use the Shutdown-r or reboot command. The system is transferred to the execution level.


5. System execution level view. can be implemented by executing command mode or viewing the configuration file:

(1). Execute Command mode: Use the RunLevel command to view the execution level of the previous and current system.

Enter the RunLevel command at the command line, which looks at the/etc/run/utmp file. and outputs the previous and current execution levels on the standard output device. For example, as seen in:

N 5 indicates an unknown execution level. The current execution level is 5, which is the XFREE86 system (graphical mode) that the current execution level has initiated for itself.

(2). How to view the configuration file, how to view the configuration file only to see the current execution level of the system, the system configuration file is/etc/inittab:

We can open it through the file editor, and we can view it using the command to open the file. At the command line, enter: Gedit/etc/inittab. That

See the red arrow pointing at the box, Id:5:initdefault:. The 5 in this line indicates that the current default system execution level is 5.


6. System execution level switching can be achieved by executing the command or by altering the configuration file:

(1). Execute command mode, Linux system at any time in the implementation of the need to switch the system execution level, switch command has two:

Command one: init [0123456Ss]

Command two: Telinit [0123456sSQqabcUu]

Description of the number of references:

0~6: Switches to the specified system execution level.

A,b,c: For those specified in the/etc/inittab file can be in a A, B. Processes executed in the C execution level.

s or S: Switch to single-user mode.

Q or Q: Check the/etc/inittab file again.

U or u: make the/etc/inittab file run again, keep the current state, and check the/etc/inittab file again.

Because the system is installing or uninstalling some of the file systems, shutting down and opening some of the services because of an execution level switch. Allocate additional resources, so. Execution-level switching takes a certain amount of time, so don't think there's something wrong with drinking a glass of water to rest. Each time the execution level is switched, the system returns to the user login interface again, requiring the user to log in again.


Next we can enter command one in the above command, and enter the command at the command line: Init 1. Enter single-user mode. For example, as seen in:

Press ENTER to run this command after running for example the following:

into single-user mode, we were able to enter the command: Init 2. Enter multi-user mode (without network File system NFS support), for example, as seen in:

Press the ENTER key. After you run this command, such as the following:

After entering the login name and password, the interface appears:

Then we want to go back to the graphical interface just now and be able to enter Init 5 to proactively start the XFREE86 system (graphically), for example, as seen in:

Press the ENTER key. After you run this command, such as the following:

After entering username and password, a graphical interface is entered.

Let's try to use command two to see if we can switch the system execution level? Enter Command Telinit 6 to see if it starts again, enter the command:

The red box is a reboot of the system.

(2). Switch system execution level can also change the configuration file mode, change the configuration file mode is directly to the/etc/inittab file in the default execution level changes to the execution level to be set up and save (in the 5th above, described how to open the file and view the default system execution level), But this way needs to start the system again. The ability to make the execution level effective, so. It is more convenient to switch the system execution level in actual use with the execution of commands.


8. Next, the service at the system execution level is introduced, and the services started at different execution levels are different, and these services are also known as Daemons under Linux. Users can see which services the Linux system has started and shut down in character or graphics mode. You can also change the default settings in the installation in character or graphics mode. The service you need is turned on or off.

(1). The following describes how to view the service by command, enter the command at the command line: Chkconfig--list. For example, as seen in:

The displayed results are divided from left to right: Service name, execution level, state.

(2). The following describes how to view system execution level services using graphical methods. For example, as seen in:

Click the red arrow pointing point, also services. Ability to start the Service Setup program:

check box tick is open service, not ticked is not open service.


9. The standalone daemon is managed by the Init script file, and all script files that are executed independently of the daemon are placed under the/etc/rc.d/init.d folder. And in the/ETC/RC.D/RCX.D. There are many symbolic link files that start with K or S, which point to script files in the/etc/rc.d/init.d folder, and files that begin with k indicate that a service is to be terminated at execution level switching. A file that begins with s indicates that a service is started when the execution level switches. We can simply understand that K is kill. That kills. S is start, which is started.

We were able to switch to the/ETC/RC.D/RC0.D folder. To view these linked files:

(1). Enter commands Cd/etc/rc.d/rc0.d and ls-l, respectively. For example, as seen in:

Can see here the link file is pointing to: Files under the/init.d/folder. This one.. Refers to the parent folder, the parent folder of the Init.d folder is the/etc/rc.d folder, that is, the link file points to the file under the/etc/rc.d/init.d folder.


10. The setup of the system execution level service can be implemented by command or graphical means:

(1). Command mode: In character mode, the command can be used to set the service on or off. The SET command is: NTSYSV, after running the command for example as seen:

Use the cursor keys or mouse to move the scroll bar to the service item you want to set, press SPACEBAR or click the option box with the mouse, select * to indicate, if the service is not required. Then press the SPACEBAR or click the Options box with the mouse. None of the selected symbols are represented by any symbol. The service is turned on or turned off. How do you click OK and CancelButton, you can use the TAB key to select OK and Cancel.

You can also execute the Setup command, and then select the System Services menu item and press ENTER to set it.

(2) graphical way, the same as the graphical way of service viewing. The second section of the 8th above, the service can be set.


11. I am also a beginner Linux, the above content is only for everyone to study the use of the test, but also conducive to my knowledge of learning accumulation. So write a bad place please forgive me, if there are errors, please point out, thank you!

??

Linux Learning Note (iii): System execution level and execution level switching

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.