Use init to switch to Linux running level

Source: Internet
Author: User
You may find that/sbin has an init command. Do you know how it is used?

If you do not like graphical logon, how can you enable the user to run the startx command on the console?

Sometimes you want to maintain the server and do not want other users to log on to the system, but you still have access to the network. What should you do?

In fact, if you know the relationship between the three problems, they will not be a problem. Let's take a look at the running level of Linux!

In fact, init is the root process in Linux and the ancestor of all processes in the system. It is mainly used to generate processes based on a script program recorded in the/etc/inittab. This file is usually used to control the user logon mode. Valid logon modes for Linux are 0 ~ There are a total of 10 types, but the limits of up to 6 types of UNIX systems are used, generally only 1 to 6 are valid.

Init generally runs automatically when the system starts. It can also be called by the root user. It is used to switch the running status of the system. The command format is INIT num <press enter>. Num indicates any number from 1 to 6.

Two of the six modes are determined by the system:

0: Stop the system. Init 0 <press enter> is equivalent to halt <press enter> 〉.

6. restart the system. Init 6 <press enter> is equivalent to reboot <press enter> 〉.

If you know the/etc/inittab file, do not set 0 to the default logon mode. Otherwise, your Linux operating system will only have 2.1 lines-boot success → shutdown, or an infinite loop of reboot → restart.

The other four modes are determined by the operating system. If you are willing to modify the source code of Linux, you can also define the actual functions of these four (or even six) modes. In fact, it is enough to know the conventions of the Linux release vendor. Let's take the blue point 2.0 as an example to see the common conventions of init --

Init 1 -- enter single-user mode.

This is the same as choosing Safe Mode when starting the system. You can manage the system with root permissions, but cannot enter the graphic Mode or Chinese characters, sound cards and network services are not required. In short, it is the minimum software and hardware configuration that the system can run.

It is similar to the Windows security mode, but the essential difference is that as long as you run the corresponding commands in Linux, hardware devices can be driven in this mode. For example, if your optical drive is correctly connected, a mount/dev/cdrom command allows you to read the content of your optical drive at any time in/mnt/cdrom.

Note that the character console in this mode cannot support Chinese characters, but you can still see the beautiful Chinese font on the blue dot in Xwin mode, and the input method is completely correct.

Init 2 -- enter the multi-user mode without Network Services

If your computer has no network connection at all, this mode will be the same as the normal mode. Otherwise, others will not be able to log on to your computer through the network www, ftp or telnet, but will still respond to the ping command on your computer. If the ping command is rejected, we recommend that you unplug the network cable! If your computer acts as a network server, this mode will be quite useful. For example, if you want to refresh the system or update the website content, you can adjust the computer to this mode and perform your work with confidence, after the work is completed, switch to Mode 3 or 5. However, if a user has already logged on to your system through ftp or telnet, using init 2 won't interrupt the connection between the user and you. Please be careful when someone else gets away with you! -- Run the who command before executing init 2.

In this mode, the usage on the local machine remains unchanged. You can still access the network, the Internet, ftp, or telnet to any server in the network. Your computer does not provide services to other machines on the network. When the computer is transferred from 3rd running level to this mode, you will see a series of network services stopped.

Init 3 or init 4-Multi-User Login mode on the console

This is the default logon mode of blue point 1.0. Every user must log on from the black and white screens before running startx can enter the KDE wonderful graphic world. After xwin is started, the console that runs startx will be locked, unless you use startx & to run xwin in the background. To go to another console, use CTRL + ALT + F * to indicate any one of the numbers 1 to 6, CTRL + ALT + F7 then return to the graphics mode dedicated 7 Console (sometimes use CTRL + ALT + F8 ).

If you switch from init 1 or init 2 back to init 3, we can see that a series of services are restarted.

Init 5 -- enter the multi-user mode of graphical login

This is the default startup mode after Blue Point 2.0 is installed. After the system starts or runs the init 5 command, a beautiful logon window appears on the blue-green transition background.

All account names are displayed in the window as icons, so you do not have to enter them yourself. However, the system administrator may be unhappy-isn't it clear how many users in the system? However, modification in the KDE control center can solve the problem.

If a problem occurs in the system, you can still enter this interface as long as the system is started (indicating that there is no problem with the X server). The root account can also enter the Linux security mode from here, in the lower-left selection box, change the mode from KDE to save failed. Of course, the interface is definitely not beautiful, but it is essential to fix the problems of the X Window Manager or application.

When the login window appears, the console from 1 to 6 is often locked. However, after a user successfully or fails to log on to the console, the console from 1 to 6 becomes available. Is it a bit confusing? Sometimes you have to press a few more keys or even Ctrl + C after switching.

Now let's solve the second problem mentioned at the beginning of the article-there are two methods: the traditional method is to run the setup command as root and reconfigure the X Window System, specify that the image mode is not automatically entered when the system is started next time. Another method is to go to one of the 1 to 6 in the console, and type init 3 <press enter> 〉, the graphical logon window disappears from the console 7, and any user can log on to the system using startx.

The init 5 mode cannot be switched too much with other modes. Otherwise, Linux will start to feel bad about itself, so it will restart the computer to restore itself-Linux sometimes needs to sneeze.

More in-depth understanding ......

Are the modes described above enough?

If you want to know more, Run man init to see the full version of the Manual. The boring manual will tell you: the command init can be combined with a series of files in the/etc directory to implement in-depth customization settings for your system startup ...... Ordinary users do not have to worry about it.

Author: He biyun
Reprinted: www.bluepoint.com

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.