Linux RunLevel and Chkconfig usage

Source: Internet
Author: User

Linux the operating level and Chkconfig usage

First, The operating level of Linux

In the case of MySQL, only to know the Linux running level of this thing. Sweat... Myself too water ... Here's a summary:

What is the runlevel? In simple terms, the runlevel is the functional level that the operating system is currently running. The levels are from 0 to 6 and have different functions. These levels are defined in the/ect/inittab file. This file is the main file that the INIT program looks for, and the first service to run is those files that are placed in the/ECT/RC.D directory.

Linux under the 7 operating level:

0à system down state, the default operating level of the system cannot be set to 0, otherwise it will not start normally, the machine shuts down.

1à Single user working status, root privileges, for system maintenance, prohibit remote login, just like Windows Safe Mode login.

2à Multi-user state with no NFS support.

3à full Multi-user mode with NFS, login to console command line mode.

4à system is not used, reserved generally not, in some special cases can use it to do something. For example, you can switch to this mode to do some setup when your laptop's battery is running out.

5àx11 console, after landing into the graphical GUI mode, X window System.

6à the system shuts down and restarts normally, the default RunLevel cannot be set to 6, otherwise it will not start normally. Running the init 6 machine will restart.

Operating level principle:

1. There are many server scripts under directory/ETC/RC.D/INIT.D, commonly referred to as services (service)
2. Under/ETC/RC.D There are 7 directories named RCN.D, corresponding to the 7 operating levels of the system

3.RCN.D directories are symbolic link files that point to a service script file under the INIT.D directory, with a naming convention of k+nn+ service name or s+nn+ service name, where NN is a two-digit number.

4. The system will enter the corresponding RCN.D directory according to the specified RunLevel, and retrieve the linked files in the directory according to the file name order: For files starting with K, the system will terminate the corresponding service; For files beginning with S, the system will start the corresponding services

5. Viewing runlevel: RunLevel

6. Enter other RunLevel: Init N, if init 3 enters terminal mode, init 5 logs in GUI mode again

7. Additional Init0 for shutdown, init 6 reboot system

The standard Linux run level is 3 or 5, and if it is 3, the system is in multi-user state, and if it is 5, it is running the X Window System.

Different operational levels have different uses, and should be set according to their own different situations. For example, if you lose the root password, you can set the machine to boot into a single-user state. At the Lilo prompt after startup, enter:

Init=/bin/sh RW

This allows the machine to enter run Level 1 and hang the root file system as read-write. It will pass through all system certifications, allowing you to use the PASSWD program to change the root password and then boot to a new run level.

Second, Chkconfig usage

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

Use syntax:

chkconfig [--add][--del][--list][system service] or Chkconfig [--level < class Code >][system service][on/off/reset]

Parameter usage:

--addà adds the specified system service, allows the CHKCONFIG directive to manage it, and adds relevant data to the system-initiated narrative file.

--delà deletes the specified system service, is no longer managed by the Chkconfig directive, and deletes the relevant data within the system-initiated narrative file.

--level< Class Code >à specifies which execution level the read system service is to open or close.

Examples of Use:

Chkconfig--list List of all system services

Chkconfig--add httpd Add httpd Service

Chkconfig--del httpd Delete httpd service

Chkconfig--level httpd 2345 on httpd is on when the operation level is 2, 3, 4, 5.

The Chkconfig command provides an easy way to set the runlevel of a service. For example, to set up a MySQL server to run at run Level 3 and 4, you must first add MySQL as a service managed by Chkconfig:

Chkconfig--add MySQL

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

Chkconfig--level MySQL on

Set to off at other levels

Chkconfig--level 01246 MySQL off

To verify that your configuration has been modified correctly, we can list the runlevel at which the service will run, as follows:

#chkconfig--list MySQL

MySQL 0:off 1:off 2:off 3:on 4:off 5:on 6:off

Linux RunLevel and Chkconfig usage

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.