Overview of seven operating level principles for Linux

Source: Internet
Author: User
Tags domain name server

The so-called runlevel, Simple point, is the level of functionality 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.

First, the operating level of Linux:

7 operating levels under Linux:

0: System shutdown status, the system default operation level 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 security mode login. 2: Multi-user status, no NFS support. 3: Full multi-user mode, NFS, login to console command line mode. 4: The system is not used, reserved for general use, in some special cases you can use it to do some things. 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, Xwindow system. 6: The system shuts down gracefully and restarts, the default runlevel cannot be set to 6, otherwise it will not start normally. Running the INIT6 machine will restart.

Standard Linux Run level is 3 or 5

Operating level principle:

1. There are many server scripts under directory/ETC/RC.D/INIT.D, commonly referred to as Service 2./etc/ RC.D There are 7 directories named RCN.D, the corresponding system of the 7 RunLevel 3.RCN.D directory is a number of symbolic link files, which point to the INIT.D directory of service script files, naming rules for the k+nn+ 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 beginning with K (Kill), the system terminates the corresponding service; For files beginning with S (start), The system will start the corresponding service 5. View RunLevel by: Runlevel6. Go to other RunLevel: INITN, if INIT3 enters terminal mode, INIT5 logs GUI mode 7 again. Init0 for shutdown, init6 restart 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 Xwindow 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/shrw

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.

Ii. usage of Chkconfig

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 simultaneously adds the 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 in 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 all system services Chkconfig--add httpd add httpd service chkconfig--del httpd Delete httpd service chkconfig--level httpd 2345 on put H The TTPD is on with a running level of 2, 3, 4, and 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

 MySQL on

Set to off at other levels

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--0123456: Off

---------------------------------

Boot start can also be in/etc/init.d/some scripts, online search under/ETC/INIT.D/HTTPD start

Add Permission chmod A+x/etc/init.d/nginx

See Run No: PS aux |grep nginx

---------------------------------

Linux Run Level

To enter Linux as an administrator, modify the file:/etc/inittab

Find "Id:5:initdefault:" 5 of which is X-window, which is the default RunLevel

Linux starts running at one level, and these run levels are listed below:

0 System Stop

1 Single user system, no login required

2 Multi-user system but NFS not supported, command-line mode login

3 full multi-user mode, command-line mode login

4 Not used

5 X11 Graphics mode, graphical mode login

6 Rebooting the system

These can be seen in the/etc/initab file in 0-6 levels of comments, the code snippet is as follows:

# Default RunLevel. The runlevels used by RHS is:

# 0-halt (do not set Initdefault to this)

# 1-single User mode

# 2-multiuser, without NFS (the same as 3, if you don't have networking)

# 3-full Multiuser mode

# 4-unused

# 5-x11

# 6-reboot (do not set Initdefault to this)

1. Level 0

The system stops. Be careful not to set this level to the default mode, or the system will stop automatically after each boot and cannot be entered.

This runlevel is primarily used to close tasks, and the individual connection commands in the RC0.D directory are commands at this level. When closed, these commands are executed one by one. They will kill all processes, shut down virtual memory and swap files, unmount the file system, and swap partitions.

The shutdown operation is completely different under DOS and Linux. At the DOS prompt, you can safely turn off the power directly. However, it is not possible to do so under Linux. The Linux file system is mounted at startup and is uninstalled when it is closed. This difference is the premise of Linux's powerful capabilities.

Under Linux, to shut down, restart the computer, or by pressing the hotkey "Ctrl" + "Alt" + "Del" to restart by entering the command shutdown plus parameters.

2. Level 1

Single-user mode. This mode only permits one user to log on to all files in the RC1.D directory from the local computer to be connected to this runlevel. This runlevel is typically used for system management and maintenance, such as upgrading Linux systems, installing new software, and so on.

In this mode, only the administrator can enter and other users cannot log on. Because the file system is loaded at startup and the network is not loaded, you cannot log on through the network.

3. Level 2

Multi-user mode. Users can log on through the network. In cases where the network is not supported, the mode and mode 3 are phase, and all files in the RC2.D directory are connected to this level.

4. Level 3

Full multi-user mode. This is the default run mode, in which all network service programs run together. The files recorded by RC3.D are connected to this level.

5. Level 4

The RC4.D directory is connected to this level without using the pattern. This level is a user-defined runlevel that the user can define by their roots. If you want to run this level, you must put the connection file in the RC3.D directory, just like any other rc*.d directory, and indicate whether the process is started or terminated.

6. Level 5

Running X Window under Linux is the use of this level. Under this level, the named of the domain name server in addition to the Internet is different from level 3, the rest is the same.

7. Level 6

This is the runlevel for restarting the system. The RC6.D directory is connected to this level. Since it is a reboot that shuts down the current system, but does not turn off the power, the connection under this directory is basically the same as the connection at level 0 under RC0.D. The difference is that although they all execute the halt (Close) command, the parameters passed to the halt are different, so level 6 can reboot the system.

Overview of seven operating level principles for Linux

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.