In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how the Ubuntu startup process is". In the daily operation, I believe many people have doubts about how the Ubuntu startup process is. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "how the Ubuntu startup process is". Next, please follow the editor to study!
Ubuntu startup process
The Ubuntu startup process is different from the way we are familiar with RedHat startup.
This is the linux startup process that we are familiar with, but the Ubuntu startup process is a little different from this. I couldn't find the file inittab in the / etc/ directory of Ubuntu. At first, I wondered how Ubuntu started. A check of information found that Ubuntu did not use init method, so / etc/ directory can not find inittab, this is mainly because init uses serial mode, boot is very time-consuming, RedHat9 startup serial execution of a large number of scripts and start a variety of required services, so from Ubuntu6.10 gradually use upstart to replace init for service process management. In order to be backward compatible with the original init implementation, upstart can be said to retain most of the features of the original init on the surface, so the name of the Ubuntu initialization process is still init, and the core of the change is the Event mechanism.
The Event mechanism regards the triggering and stopping of the process as Event. Under / etc/ of the Ubuntu startup process, there is an event.d, which is the core of upstart. / etc/event.d/ stores all kinds of event that upstart needs to identify. Among them, there are mainly three kinds: rc-default,rcX (X = 0meme 1, 2), 3 3, 4, 5, 6) and ttyX (X = 0, 1, 2, 3, 4, 5, 6, S).
Rc-default is similar to the inittab file, which is used to set the default run level. Cat rc-default, we can see:
# rc-runlevel compatibility
# This task guesses what the "default runlevel" should be and starts the
# appropriate script.
Start on stopped rcS script
Runlevel-- reboot | | true
If grep-Q-w-"- s\ | single\ | S" / proc/cmdline; then
Telinit S
Elif [- r / etc/inittab]; then
RL= "$(sed-n-e" / ^ id: [0-9] *: initdefault:/ {s / ^ id: / /; s etc/inittab etc/inittab} "/ true)"
If [- n "$RL"]; then
Telinit $RL
Else
Telinit 2
Fi
Else
Telinit 2
Fi
End script
The default run level is 2.
RcX is the script that needs to run the program when the corresponding run-level event occurs. Let's cat the rc2:
# rc2-runlevel 2 compatibility
# This task runs the old sysv-rc runlevel 2 ("multi-user") scripts. It
# is usually started by the telinit compatibility wrapper.
Start on runlevel 2
Stop on runlevel [! 2]
Console output
Script
Set $(runlevel-- set 2 | | true)
If ["$1"! = "unknown"]; then
PREVLEVEL=$1
RUNLEVEL=$2
Export PREVLEVEL RUNLEVEL
Fi
Exec / etc/init.d/rc 2
End script
Instead of thinking about the details, just pay attention to the first two lines and the penultimate line. As you can see, the rc2 file defines what to execute when run level 2 occurs, and the core is this sentence: exec / etc/init.d/rc 2. In this way, we can naturally transition to the next important directory, / etc/init.d/.
All the scripts stored in / etc/init.d/ are execution scripts for services or tasks. It can be said that as long as you install a program (especially the server daemon) that runs when the system Ubuntu starts the process, it must have a script file in / etc/init.d/. Going back to the above rc2, it executes exec / etc/init.d/rc 2, that is, passing a parameter "2" to / etc/init.d/rc for it to execute. There is a paragraph in the Rc script:
# Now run the START scripts for this runlevel.
# Run all scripts with the same level in parallel
For s in / etc/rc$runlevel.d/S*
This means that when you pass a numeric parameter "X" to the rc script, it will start executing the script starting with S under / etc/rcX.d/ after a series of settings. This transitions to the next directory / etc/rcX.d/.
Ls / etc/rcX.d/, finds that it is full of script symbolic links to / etc/init.d/, except that they start with S and a number. Anyone familiar with the original init should know that S means to run at startup, and the number indicates the order of execution. One of the links is called S30gdm GDM, which means gnome display management, which is used to launch the gnome desktop.
II. Analysis of x-window startup process
Entering X from the console usually uses the startx command, so startup should start with the script startx. The following is part of the startx script:
#! / bin/sh
Userclientrc=$HOME/.xinitrc # user's client definition file
Userserverrc=$HOME/.xserverrc # user's server definition file
Client of the sysclientrc=/usr/X11R6/lib/X11/xinit/xinitrc # system
Server of the sysserverrc=/usr/X11R6/lib/X11/xinit/xserverrc # system
Defaultclient=/usr/X11R6/bin/xterm # default client program
Defaultserver=/usr/X11R6/bin/X # default server program
Parameter variables for client and server are defined under defaultclientargs= ""
Defaultserverargs= ""
Clientargs= ""
Serverargs= ""
As you can see, startx mainly sets the location of X client and X server, and processes the relevant parameters, which is handed over to xinit for processing. You can see that startx sets the location of X client to search for $HOME/.xinitrc first, and then / etc/X11/xinit/xinitrc; sets the location of X server to search for $HOME/.xserverrc first, then / etc/X11/xinit/xserverrc. There are no .xinitrc and .xerverrc under $HOME in Ubuntu8.10, so startx goes directly to / etc/ to find x-client and x-server to complete the Ubuntu startup process.
At this point, the study of "what is the start-up process of Ubuntu" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.