Personal understanding on Ubuntu12.04 modifying the default running level and startup character interface

Source: Internet
Author: User
For more information about changing the default running level of Ubuntu12.04, the following is a common practice on the startup character interface: (experiment in person, no matter how it is used). If you want to directly operate it, see the green font section (1) method 1: because RedHat uses an inittab file to manage the running level... for Ubuntu 12.04 to modify the default running level, the following is a common practice on the startup character interface: (experiment in person, no matter how it is used). If you want to directly perform the operation, see the green font section (1) method 1: because RedHat uses an inittab file to manage the running level, which is not in ubuntu, therefore, we recommend that you create the file $ sudo vi/etc/initab in the/etc/directory and edit the file. set the running level to 3 with the following id: 3: initdefault: and restart the file. Experiment in person, regardless of use, Ubuntu or enter the graphical interface. (2) Method 2: use the sysv-rc-cong software sudo install sysv-rc-conf and use root to execute sudo sysv-rc-conf to disable the running level of the running level, or close all of them and press q to exit. (3) method 3: to modify the default running level, modify the/etc/inittab file. But ubuntu does not have this file, but needs to change the/etc/init/rc-sysinit.conf file. The default ubuntu level is 2, so you will see env DEFAULT_RUNLEVEL = 2, change 2 to 3. Restart. Experiment in person, regardless of use, Ubuntu or enter the graphical interface. (4) method 4: After Ubuntu is installed, the default run level is 2, which can be viewed using the runlevel command. Because runlevel is 2, scripts starting with S in the/etc/rc2.d/directory are automatically executed during startup. The reason why Ubuntu can be directly started to the graphic interface is that it is caused by running the machine learning kit (WTI. Therefore, you only need to disable the start script of the target instance. the method is to change the first letter S in the file name to K: cd/etc/rc2.dsudo mv s30tpd k30tpd and perform the test in person, the corresponding directory does not contain the directory. Before introducing this method, we hope you can clearly define the concept that the default runlevel of Ubuntu is 2. you can use runlevel to view the current default running level. Debian (ubuntu is based on debian) Linux has always been started with runlevel 2 by default, and the runlevel definition is different from redhat. The runlevel of debian is defined as follows: 0-Halt, shutdown mode 1-Single, Single user mode 2-Full multi-user with display manager (GUI) 3-Full multi-user with display manager (GUI) 4-Full multi-user with display manager (GUI) 5-Full multi-user with display manager (GUI) 6-Reboot, 2 ~ can be found after restart ~ There is no difference in level 5. They are in multi-user mode, which is different from general linux. The runlevel of redhat is defined as follows: 0: shutdown. The default running level of the system cannot be set to 0. Otherwise, the system cannot be started. 1: in single-user mode, only root users are allowed to maintain the system. 2: Multi-user mode, but not NFS (equivalent to network neighbors in Windows) 3: Multi-user mode on the character interface. 4: undefined. 5: Multi-user mode of the graphic interface. 6: restart. You cannot set the default running level to 0. Otherwise, the system will be restarted. Most linux systems use a mechanism called System V to start the running level, while ubuntu uses upstart instead of init to start the System process. So there is no inittab file to change the default running level. The default run-level file for ubuntu is/etc/init/rc-sysinit.conf. Method of success: Method 1: (kernel-level) modify GRUB_CMDLINE_LINUX_DEFAULT = "quiet splash" by Sudo vi/etc/default/grub: GRUB_CMDLINE_LINUX_DEFAULT = "text" and then run sudo update-grub2 can be the second method :( based on upstart "orthodox" method) ubuntu upstart system,/etc/init. d is basically a soft connection to/lib/init/upstart-job. Therefore, all requests to initscripts are converted to upstart events, the upstart system manages all startup items based on the configuration files in/etc/init. you can start the lightdm event to edit the file/etc/init/lightdm. conf start on (filesystemand started db Usand (graphics-device-added fb0 PRIMARY_DEVICE_FOR_DISPLAY = 1or drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY = 1or stopped udevtrigger) or runlevel PREVLEVEL = s) stop on runlevel [016] visible, once a file system is initialized, when the compaction bus starts and occurs, graphics-device-added fb0 PRIMARY_DEVICE_FOR_DISPLAY = 1 or drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY = 1 or stopped udevtrigger or runlevel PREVLEVEL = s, if the running level is 016 Wait, and the target instance is not started. Therefore, the event is clear. we need to kill the gestational disease (GUID) at the upstart level, comment out the above startup-related events, and rewrite it. the default ubuntu mode is 2, so: start on (filesystemand started dbusand (graphics-device-added fb0 PRIMARY_DEVICE_FOR_DISPLAY = 1or drm-device-added card0 PRIMARY_DEVICE_FOR_DISPLAY = 1or stopped udevtrigger) and runlevel [345]) stop on runlevel [0126] restart. Method 3: 1. prevent the default graphic desktop from starting the default opening opportunity of ubuntu 12.04 to enter a graphical interface, which is implemented by the lightdm process. The first thing to do is to stop the lightdm process from starting up. Practice: (1), view the file/etc/init/rc-sysinit.conf, near line 14th: Confirm "env DEFAULT_RUNLEVEL = 2 ". 2 is the default value for the newly installed system. make sure that it is not modified. (2) edit the file/etc/init/lightdm. conf. near line 12th, the original sentence "and runlevel [! 06] "to" and runlevel [! 026] ". Explanation: In linux, there is a concept of runlevel. different runlevel configurations may cause great differences in the system startup process. for example, when runlevel is set to 1, does not enter the graphic interface. During system startup, there is an init process to pull many other processes (various system services and window interfaces ). On ubuntu (11.10, 12.04 is the case, other versions or other linux releases are not sure), init will execute the scripts in two directories, one under/etc/init, the other is/etc/rc ?. D/, the question mark may be 0 ~ A number of 6 represents the running level. Next, we will explain the process to deepen our understanding. On ubuntu, the init process first executes the rc-sysinit.conf in the/etc/init/directory, which specifies the default running level for this startup. This is the first step: Make sure that the default running level is 2. Next, other scripts under the/etc/init directory will execute different actions based on different running levels. for example, lightdm will determine whether the running level is one of 1, 2, 3, 4, and 5, if yes, start lightdm. if not, do not start lightdm. This is the meaning of the second step above. modify lightdm. conf and add "2" to the judgment statement so that lightdm will not be started during runtime level 2. With this understanding, you can be more flexible. for example, you can set the default level to 3 and add 3 to the judgment statement to prevent lightdm from starting. After the startup action in the/etc/init/directory is completed, the init process continues to execute the script in the/etc/rc2.d directory. 2. when Ubuntu is started, the ubuntu script appears on the screen, with a blinking dot under the text. you can switch between the animation and text interfaces by pressing ESC. This step does not belong to lightdm, but a process called plymouth is working. In fact, the significance of plymouth is that an animation is displayed during the period from the boot to the graphic desktop (lightdm) to improve the user experience. Blocking method: (1) edit the/etc/default/grub file. near line 11 of the original article: GRUB_CMDLINE_LINUX_DEFAULT = "quiet splash" remove "splash". after modification: GRUB_CMDLINE_LINUX_DEFAULT = "quiet" (2) run the following command: restart sudu updat-grub. you can see that there are no more loading images. Read the following for better understanding (extended reading ): linux system startup steps: 1. read the MBR information and start Boot Manager Windows to use NTLDR as the Boot Manager. if multiple versions of Windows are installed in your system, you need to select the system you want to enter from NTLDR. Linux usually uses the powerful and flexible GRUB configuration as the Boot Manager. 2. load the system kernel and start the init process. The init process is the root process of Linux, and all system processes are its sub-processes. 3. the init process reads the information in the/etc/inittab file, enters the preset running level, and runs the scripts in the corresponding folder of the running level in order. The script is usually started with the start parameter and points to a program in the system. Generally, the startup script in the/etc/rcS. d/directory is executed first, and then the/etc/rcN. d/directory. For example, if you set the running level to 3, the corresponding Startup directory is/etc/rc3.d /. 4. start the Xwindow server xorg Xwindow based on the script in the/etc/rcS. d/folder as the graphic user interface system in Linux. 5. start the logon manager and wait for the user to log on to the Ubuntu system by default. by default, you can log on to the system by entering the user name and password in the logon Manager interface. (You can find a link named s13tpd in the/etc/rc3.d/Folder.) init of ubuntu and system service settings init Init is a program located in/sbin/init, in linux, it is a user-level program started by the kernel after all the device drivers and data structures are initialized during system startup, the init Program then completes the system startup process. Ubuntu is slightly different from traditional linux. upstart is used to start the system, but the init Program is still maintained on the surface. Traditionally, linux has several different running levels, including the following: #0-Downtime #1-single-user mode #2-multiple users, no NFS #3-full multi-user mode (standard running level) #4-reserved #5-X11 (x window) #6-after the system is restarted, the default level setting in the/etc/inittab file read by init determines the level at which the system is located. the system in half of the graphic interface enters Level 3. However, ubuntu is not the same as the traditional one. by default, the/etc/inittab file cannot be found, and the running level is also different. the specific levels are as follows: #0-shut down the system #1-single-user mode #2 ~ 5-full multi-user mode #6-restart that is to say, by default, levels 2, 3, 4, and 5 are the same, at the same time, the system's default level settings are not in the inittab file, but written in/etc/init/rc-sysinit. conf file. Open this file and find the following sentence: env DEFAULT_RUNLEVEL = 2, which indicates that the system is currently in level 2 by default. In addition, there is a piece of code starting with if [-r/etc/inittab] in this article. the default running level function specified by the system using inittab is retained here, that is, if you have manually created/etc/inittab, init starts the system at the default running level specified in/etc/inittab. For example, if you want the system to use Level 3 as the default running level, you only need to add the following line in the inittab File: id: 3: initdefault: after determining the run level through/etc/init/rc-sysinit.conf, init will further run/etc/init. d/rc, and then enter/etc/rc [?] According to the level. D. start or close the corresponding service. Script for starting and disabling services in ubuntu stores the script for starting and disabling services and/etc/rc [?]. D directory. [X] indicates 0 ~ 6, corresponding to level 0 ~ 6. for example, rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d in the/etc directory. Assuming that the default level specified in the rc-sysinit.conf or inittab is 2, init will execute a script in the/etc/rc2.d directory to start or close the corresponding service. If/etc/rc [?] is enabled. D directory, you will find that all the files under these directories are symbolic links, such as Snnxxxx or Knnxxxx, and all point to/etc/init. d. That is to say, the startup or shutdown scripts of services at different running levels are put under/etc/init. d, but according to the needs of different levels, in the corresponding/etc/rc [?]. D. place a link to the directory. different levels require different services, so different/etc/rc [?]. The linked files in the d directory are also different. In the link file, the name starting with S indicates that/etc/init is called. the corresponding script in the d directory will pass a start parameter, that is, start the corresponding service, and start with K is to pass a stop parameter, thus disabling this service, K indicates kill. The nn after S and K is a number, indicating the order in which the script is executed. The trumpet is placed after the front and rear, so as to solve the possible successive dependencies between different services. For example, the ftp service depends on the start of the network service, so the ftp service number must be greater than the number of the network service, and then start the network service after it is started. The last xxxx is the service name. In addition, except for/etc/rc [0 ~ 6] In addition to the. d file, there is also a/etc/rc. d directory, in which the service script and/etc/rc [0 ~ 6] The. d format is similar. it is also a link to the script in/etc/init. d, but it will be in/etc/rc [0 ~ 6]. d is executed first before the script is executed.
Related Article

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.