Use init to play Linux run level

xiaoxiao2021-03-06  94

Maybe everyone will accidentally find that there is an init command in Sbin. Do you know how it is used?

If you don't like to use a graphic login method, how can you let the user run the startX command under the console?

Sometimes you have to maintain the server, don't want other user login systems, but I still have access to the Internet, what should I do?

In fact, if you know the relationship between three issues, they are not a problem. Let us start to learn about Linux's run level (Runlevel)!

In fact, init is the root process in the Linux system, which is the ancestors of all systems. Its main role is to generate a process based on a script program recorded in / etc / inittab. This file is usually used to control the user's login mode. The effective login mode of the Linux system has 0 to 9, but the limit of up to 6 of the UNIX system is usually only 1 to 6 effective.

INIT typically runs automatically when the system is started, or it can be called by the root user. Its role is toggle the operating status of the system. Its command format is: Init Num , where NUM represents any number of 1 to 6.

There are two types of patterns that are systemical:

0: Stop the system run. INIT 0 Equivalent to HALT

6: Restart the system. INIT 6 Equivalent to Reboot

If you know the / etc / inittab file, don't set 0 to the default login mode, otherwise your Linux runs only two-point line - boot ← → stop, or boot ← → Restart unlimited cycle.

Other four modes are actually determined by the operating system. If you are willing to modify the source code of Linux, you can also define the actual features of these four (or even 6) modes. In fact, as long as you know that Linux released the contract is enough, we will take a blue point 2.0 as an example, see the common agreement of INIT -

INIT 1 - Enter a single user mode.

This is the same as the boot is the same. You can manage the system with root permissions, but you can't enter graphic mode, and you don't support Chinese, sound cards and network services. In short, it is the lowest hardware configuration that the system can run.

It is similar to Windows security model, but an essential difference: The hardware device can be driven in this mode as long as you run the corresponding command under Linux. For example, as long as your optical drive is connected correctly, a mount / dev / cdrom command, your disc content can be read at / mnt / cdrom at / mnt / cdrom at any time.

It is important to note that the character console of this mode cannot support Chinese, but enter XWIN still can see the blue spot beautiful Chinese font, and there is no problem in the input method.

INIT 2 - Multi-user mode enters no network service

If your computer is not connected at all, this mode is the same as normal mode. Otherwise, others cannot log in to your computer over the network WWW, FTP or Telnet, but it will respond to your computer with the ping command. If you also reject access, you will not pull the network directly! If your computer is used as a web server, this mode is quite useful. For example, you have to trim the system or update the content of the website, you can transfer your computer to this mode, then assured your work, wait until the work is complete, then switch to mode 3 or 5. But note that if you have already entered your system, you can't interrupt him with your connection with init 2, be careful to let others be black at this time! - Use the who command to check it with the who command before executing init 2.

In this mode, the use of the machine is basically unchanged. You can still access the network, on Internet, FTP, or Telnet to any server in the network. It's just that your computer does not provide services to other machines in the network. When the computer is transferred from the 3rd run level to this mode you will see a series of network services stopped. INIT 3 or INIT 4 - Multi-user mode enters the console login

This is the default login mode of the blue point 1.0, and each user must first log in from the black and white screen before running to enter the wonderful graphic world of KDE. And after XWIN is started, the console that runs StartX is locked unless you use StartX & to put XWIN in the background run. To do any other console with Ctrl Alt f *, * Represents any one of the numbers 1 to 6, Ctrl Alt F7 returns to the 7th console dedicated to graphics mode (sometimes Ctrl Alt F8) .

If it is switched back from INIT 1 or INIT 2 back to INIT 3, we can see that a series of services is restarted.

INIT 5 - Multi-user mode enters graphic login

This is the default startup mode after the blue point 2.0 is installed. After the system is started or executed after the init 5 command, a beautiful login window appears on the pleasing blue-green transition.

All account names appear in the window in the window, waiting for selection in the window, do not need to enter yourself. However, the system administrator may not be happy - how many users do you have in this system? However, in the KDE control center, you can solve the problem, I will not say much.

If the system has a problem, as long as the start is still able to enter this interface (indicating that the X server is not problematic), the root account can also enter Linux security mode, which is to change the mode from KDE to save faile. . Of course, the interface is absolutely no aesthetic, but the problem used to fix X-window manager or application is essential.

The login window is just 1 to 6 console is often locked. But after a user logs in to success or fail, the 1 to 6 console will become available. Is it a bit inexplicable? Sometimes you have to press a few carriages through or even Ctrl C after switching.

Now let's solve the second question raised by the article - Method has two: traditional methods are root run setup commands, reconfigure the X window system, specify that the next system starts automatically enter graphics mode; another The method is one of the console 1 to 6, type INIT 3 , the graphic login window will disappear from the 7th console, and any user can use the STARTX login system.

INIT 5 This mode cannot be switched with other modes. Otherwise, the system Linux starts self-feeling, so restarting the computer to recover the vitality - Linux sometimes sneezes.

to further understand……

Is there a few models described above?

If you want to know more, you may wish to tell Man init to take a full version of the manual, the boring manual tells you: Command Init Combine a series of files in the / etc directory can achieve in-depth customization of your system. Setting ... The general user does not have to worry about it.

Author: He Biyun

Reprinted:

Www.bluepoint.com

转载请注明原文地址:https://www.9cbs.com/read-121839.html

New Post(0)