Linux Operating Principles

Source: Internet
Author: User

In short, the running level is the currently running function level of the operating system. Levels are from 0 to 6, with different functions. These levels are defined in the/ect/inittab file. This file is the main file found by the init program. The first service to run is the files in the/ect/rc. d directory.

I. Linux running level:

Seven running levels in Linux:

0: The system is down. The default running level cannot be set to 0. Otherwise, the system cannot start normally and the machine is down. 1: single-user working status, root permission, used for system maintenance, remote login is prohibited, just like login in safe mode in Windows. 2: multi-user status, not supported by NFS.3: Full multi-user mode with NFS. After logging on to the console, go to the command line mode. 4: The system is not used. It is generally not used for reservation. In some special cases, you can use it to do some things. For example, you can switch to this mode to make some settings when the battery of your laptop is exhausted.5: X11 console. After logging on to the console, enter the graphic GUI mode, XWindow system. 6: The system is shut down and restarted normally. The default running level cannot be set to 6. Otherwise, the system cannot be started normally. If you run init6, the system restarts.

Standard Linux running level: 3 or 5

Running Level Principle:

1. in the/etc/rc. Directory. d/init. d. There are many server script programs, which are generally called Services 2. in/etc/rc. d. There are 7 names named rcN. d directory, corresponding to 7 running levels of the system 3. rcN. the d directory contains some symbolic link files that all point to init. the service script file under the d directory. The naming rule is K + nn + service name or S + nn + service name. The nn is a double digit. 4. the system will enter the corresponding rcN according to the specified running level. d directory, and search the linked files under the directory in the order of file names: For Files starting with K (Kill), the system will terminate the corresponding server; for files starting with S (Start) the system starts the corresponding service. run: runlevel6. run: initN. If init3 is run, enter terminal mode. If init5 is run, log on to graphical GUI mode. in addition, init0 indicates shutdown, and init6 indicates restarting the system.

The standard Linux operating level is 3 or 5. If it is 3, the system is in multi-user State; if it is 5, the XWindow system is running. Different running levels have different functions and should be set according to different situations. For example, if the root password is lost, you can set the machine startup status to a single user. Enter:
Init =/bin/shrw

In this way, the machine can enter level 1, and the root file system can be mounted to read/write. It passes all system authentication and allows you to change the root password using the passwd program, and then start to a new running level.

Ii. Usage of chkconfig

The chkconfig command can be used to check and set various services of the system.

Syntax:

Chkconfig [-- add] [-- del] [-- list] [System Service] Or chkconfig [-- level <level code>] [System Service] [on/off/reset]

Parameter usage:

-- Add: adds the specified system service, enables the chkconfig command to manage it, and adds relevant data in the system startup description file. -- Del: Delete the specified system service. It is no longer managed by the chkconfig command, and relevant data is also deleted in the description file started by the system. -- Level <level code>: Specifies the execution level of the read system service.

Example:

Chkconfig -- list all system services chkconfig -- add httpd service chkconfig -- del httpd Delete httpd service chkconfig -- level httpd 2345 on set httpd to 2, 3, 4, 5).

The chkconfig command provides a simple way to set the running level of a service. For example, to set the MySQL server to run on level 3 and level 4, you must first add MySQL as a service managed by chkconfig:
Chkconfig -- add mysql

Now, we set the service to "on" on level 3 and 5"

chkconfig --level 35 mysql on

Set to off at other levels

chkconfig --level 01246 mysql off

To confirm that your configuration has been correctly modified, we can list the running levels of the service, as shown below:

#chkconfig --list mysqlmysql 0:off 1:off 2:off 3:on 4:off 5:on 6:off

Original article: http://blog.csdn.net/MONKEY_D_MENG/archive/2010/05/10/5573580.aspx

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.