Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the principle of the seven runlevels of Linux

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article focuses on "what is the principle of the seven operating levels of Linux". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what is the principle of the seven operating levels of Linux"?

The so-called run level, to put it simply, is the functional level at which the operating system is currently running. The level is from 0 to 6, with 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 services that * * run are those that are placed in the / ect/rc.d directory.

1. The running level of Linux:

7 runlevels under Linux:

0: the system is in a state of downtime. The default running level of the system cannot be set to 0, otherwise it cannot start normally and the machine shuts down. 1: single user working status, root authority, for system maintenance, prohibit remote login, just like the safe mode login under Windows. 2: multi-user status, no NFS support. 3: complete multi-user mode, with NFS, enter the command line mode of the console after login. 4: the system is not in use, it is generally not used, and it can be used to do something in some special cases. For example, when the laptop battery runs out, you can switch to this mode to make some settings. 5:X11 console, log in to the graphic GUI mode, XWindow system. 6: the system shuts down and restarts normally, and the default running level cannot be set to 6, otherwise it cannot start normally. Run init6 and the machine will restart.

The standard Linux runlevel is 3 or 5

Runlevel principle:

1. There are many server scripts under the directory / etc/rc.d/init.d, commonly known as service 2. 0. There are seven directories called rcN.d under / etc/rc.d, and there are symbolic link files in the seven run-level 3.rcN.d directories of the corresponding system. These link files all point to the service script files in the init.d directory. The naming rules are Kbinnn + service name or Signornnn service name, where nn is a two-digit number. 4. The system will enter the corresponding rcN.d directory according to the specified running level, and retrieve the linked files in the directory according to the file name order: for files starting with K (Kill), the system will terminate the corresponding service; for files starting with S (Start), the system will start the corresponding service 5. Check the run level with: runlevel6. Enter other runlevels: initN, enter terminal mode if init3, and log in to graphical GUI mode 7. 7 for init5. In addition, init0 shuts down and init6 restarts the system.

The standard Linux runlevel is 3 or 5, and if it is 3, the system is in a multi-user state; if it is 5, the XWindow system is running. Different run levels have different uses and should be set according to their own situations. For example, if you lose your root password, you can set it up by booting the machine into a single-user state. Enter at the lilo prompt after startup:

Init=/bin/shrw

This allows the machine to enter run level 1 and hang the root file system as read and write. It will pass through all system authentication, let you use the passwd program to change the root password, and then boot to a new runlevel.

II. Chkconfig usage

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

Use syntax:

Chkconfig [--add] [--del] [--list] [system Services] or chkconfig [--level] [system Services] [on/off/reset]

Parameter usage:

-- add: add the specified system service so that the chkconfig instruction can manage it, and at the same time add relevant data to the narrative file started by the system. -- del: deletes the specified system service, is no longer managed by the chkconfig instruction, and deletes the relevant data in the narrative file started by the system. -- level: specify the execution level in which the read system service is enabled or closed.

Examples of use:

Chkconfig-- list lists all system services chkconfig-- add httpd adds httpd service chkconfig-- del httpd deletes httpd service chkconfig-- level httpd 2345 on makes httpd on at runlevel 2, 3, 4, 5.

The chkconfig command provides an easy way to set the run level of a service. For example, to set up the MySQL server to run at runlevels 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 35 mysql on

Set to off at other levels

Chkconfig-level 01246 mysql off

To make sure that your configuration has been modified correctly, we can list the running levels at which the service will run, as shown below:

# chkconfig-list mysqlmysql 0:off 1:off 2:off 3:on 4:off 5:on 6:off at this point, I believe you have a deeper understanding of "what is the principle of the seven runlevels of Linux". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report