Six months ago, I wrote 'How the computer is started? 'BIOS and explore the role Nike Jordan Hydro 2 of the master boot record. The article does not involve the operating system, only with the motherboard onboard procedures related. Today, I would like to then write down, investigate what happened after the operating system takes over the hardware, which is the operating system boot process. The more interesting part. Because the BIOS stage, the behavior of the computer is basically written dead, programmers can do things not many; however, once into the operating system, the programmer can customize almost all aspects. So, part of this relationship more closely with the programmers. My main concern is the Linux operating system, which is currently the mainstream of the server operating system. The following content is for Debian release, because I'm not familiar with other distributions. The first step, after loading the kernel operating system takes over the hardware, first read the kernel file into the / boot directory. In my computer, for example, / boot directory is probably some of the files: $ ls /bootconfig-3.2.0-3-amd64config-3.2.0-4-amd64grubinitrd.img-3.2.0-3-amd64initrd.img- 3.2.0-4-amd64System.map-3.2.0-3-amd64System.map-3.2.0-4-amd64vmlinuz-3.2.0-3-amd64vmlinuz-3.2.0-4-amd64 second step, start the initialization process After the kernel file to load, you start running the first program / sbin / init, its role is to initialize the system environments. Since the init program is first run, its process ID (pid) is 1. All other processes are derived from it are its children. The third step is to determine the level of many programs need to run boot. They are called 'service' (service) in Windows, in Linux is called 'daemon' (daemon). A major task of the init process, is to run these boot programs. However, different situations need to start a different program, such as when used as a server, you need to start Apache, as the desktop is not required. Linux allows for different occasions, assign different start-up program, which is called 'runlevel' (runlevel). That is, when you start according to 'run level' to determine which program to run. Linux preset seven kinds of run level (0-6). Generally, 0 is off, 1 is a single-user mode (ie maintenance mode), 6 is reboot. Run levels 2-5, each release is not the same, for Debian, it is the same multi-user mode (that is, the normal mode). init process first reads the file / etc / inittab, which is run level settings file. If you open it, you can see that the first line is this: id: 2: initdefault: the value of initdefault is 2, indicating that the system startup run level 2. If you need to specify a different level, you can manually modify this value. So, what is the procedure to run level 2 does, how to know what program the system should be loaded at each level it? ...... Answer is that each run level in / etc directory, there is a corresponding subdirectory, specify the program to be loaded. /etc/rc0.d/etc/rc1.d/etc/rc2.d/etc/rc3.d/etc/rc4.d/etc/rc5.d/etc/rc6.d above the directory name in the 'rc' representing run command (run programs), Womens Nike Lunar and finally d represents the directory (directory). Let us look in the end /etc/rc2.d catalog specifies which programs. $ Ls /etc/rc2.dREADMES01motdS13rpcbindS14nfs-commonS16binfmt-supportS16rsyslogS16sudoS17apache2S18acpid ... you can see, in addition to the first file README, other file names are 'the letter S + two-digit number + the program name' form. The letter S represents Start, which is meant to start (the operating parameters for the startup scripts start), if this position is the letter K, on behalf of the Kill (off), that if you switch over from other operating level, you need to close the program (start-up script The operating parameters for the stop). Behind two digits indicate the processing order, the lower the number the earlier the treatment, so the first start of the program is motd, then rpcbing, nfs ...... figures are the same, the program name in alphabetical order starting, so rsyslog will first in sudo start. All files in this directory (except README), that is when you start to load the program. If you want to add or remove some programs, it does not recommend manually modify /etc/rcN.d directory, it is best to use some special commands to manage (see here Mens Nike Free 3.0 Wool Skin Shoes Grey Yellow and here). The fourth step is to load the front of the boot startup programs mentioned seven preset 'run level' each of which has a directory to store boot program needs. Difficult to think that Mens Nike Free 3.0 Wool Skin Shoes Grey Navy if multiple 'run levels' Nike Lunareclipse needs to start with a program, then the program's startup script, it will have a copy in every directory. This Air Max 2011 Womens Grey Red Black will cause problems in management: If you want to modify the startup scripts, would not each directory must be changed again? Linux solutions, is the program of the seven /etc/rcN.d directory listed, are set to the linked file, pointing to another directory /etc/init.d, real startup scripts are united in this directory. init process individually loaded boot program, in fact, run the directory where the startup script. Here is the link really points to the file. $ Ls -l /etc/rc2.dREADMES01motd - \u0026 gt; ../init.d/motdS13rpcbind - \u0026 gt; ../init.d/rpcbindS14nfs-common - \u0026 gt; ../init.d/nfs-commonS16binfmt-support - \u0026 gt; ../init.d/binfmt-supportS16rsyslog - \u0026 gt; ../init.d/rsyslogS16sudo - \u0026 gt; ../init.d/sudoS17apache2 - \u0026 gt; ../init.d/apache2S18acpid - \u0026 gt; .. /init.d/acpid ... Another benefit of doing so is that if you want to manually shut down or restart a process directly to the directory /etc/init.d find startup script. For example, I want to restart Air Max 2011 Womens Grey Purple the Apache server, run the following command: $ sudo /etc/init.d/apache2 restart / etc / init.d directory name last letter d, is a directory of meaning, that this is a directory, used in conjunction with a program / etc / init distinction. The fifth step, after the user logs on start-up program is loaded, it is necessary to let the user login. In general, the user's login in three ways: (1) command line login (2) ssh login (3) GUI login these three cases, have their own way to Nike Running authenticate the user. (1) command line login: init process calls the getty program (meaning get teletype), allows the user to Air Jordan Outlet enter a user name and password. After the input is complete, then call the login program, check the password (Debian will run an identity check program more /etc/pam.d/login). If the password is correct, from the file / etc / passwd to read the user-specified shell, and then start the shell. (2) ssh login: then the system calls the sshd program (Debian will run /etc/pam.d/ssh), replace getty and login, and then start the shell. (3) GUI login: init process calls the display manager, Gnome graphical interface corresponding to the display manager gdm (GNOME Display Manager), and then enter the user name and password. If the password is correct, the read / etc / gdm3 / Xsession, start the user's session. The sixth step, enter the login shell so-called shell, it simply is a command-line interface, allowing users to speak directly with the operating system. When the user logs in open shell, called the login shell. Debian default shell is Bash, it will read a series of configuration files. Three cases in the previous step, and in this step of treatment, there are also differences. (1) Command Line Login: first reads 579827-300 Sport Turquoise Nike LeBron X PS Elite Online / etc / profile, which is effective for all users of the configuration; then turn look for the following three documents, which is configured for the current user. ~ / .bash_profile ~ / .bash_login ~ / .profile To note that these three documents as long as there is a presence, do not read into the back of the Nike Air Max document. For example, if ~ / .bash_profile exists, it will not be read into the back of two files. (2) ssh login: exactly the same as the first case. (3) GUI login: only load / etc / prfile and ~ / .profile. That is to say, ~ / .bash_profile or without, will not run. The seventh step, open non-login shell to be honest, after the previous step is completed, the Linux boot process even if the end user can already see the command line prompt or graphical interface. However, in order to complete the content, you must tell us about this step. After the user enters the operating system, often manually open a shell. This shell is called non-login shell, meaning that when it is different from the login shell, does not read the / etc / profile and .profile and other configuration files. The importance of non-login shell, and not only because it is the most contact with the user shell, but also because it will be read into the user's own bash configuration file ~ / .bashrc. Most of the time, we have to bash customization, are written in this document inside. You might ask, if it does not enter non-login shell, would not .bashrc will not run, so it can not complete customized bash? In fact, Debian has taken into account this problem, open the file ~ / .profile, you can see the following code: if [-n \u0026 quot; $ BASH_VERSION \u0026 quot;]; then if [-f 2015 Nike Free 5.0 \u0026 quot; $ HOME / .bashrc \u0026 quot; .]; then \u0026 quot; $ HOME / .bashrc Nike Free 3.0 V4 Men \u0026 quot; fifi \u0026 lt; span style = \u0026 quot; font-family: Monaco, Consolas, 'Andale Mono', 'DejaVu Sans Mono', monospace; font-style: normal; \u0026 quot; \u0026 gt; \u0026 lt; / span \u0026 gt; The above code first variable $ BASH_VERSION determine whether there is value, and then determine whether there is the .bashrc file in your home directory, then run the file if it exists. The point at the beginning of the third line, is shorthand source command indicates run a file, written in 'source ~ / .bashrc' is also possible. So, just run ~ / .profile file, ~ / .bashrc file will NIKE KD 6 NSW jointly run. But the first case mentioned in the previous section, Mens Nike Free Run 3 Shoes Blue 3 if there is ~ / .bash_profile file, you may not run ~ / .profile file. To solve this problem is very simple, writes .bash_profile code below the line. if [-f ~ / .profile];. then ~ / .profilefi Thus, in either case, .bashrc is executed, the user's settings can safely written to this file. Bash setting is so complicated, is due to historical reasons. Early on, the computer is running very slow, takes a long time to load the configuration file, Bash the author had to configuration file into several parts, stage loaded. General settings for the system in / etc / profile, individual user needs to be inherited by all child processes set in .profile, need not be inherited settings in .bashrc. Incidentally, in addition to Linux, Mac OS X using the shell is Bash. However, it only loads .bash_profile, then call in .bash_profile .bashrc inside. Moreover, whether ssh login, or start a shell window in a graphical interface, are true. Reference Links [1] Debian Wiki, Environment Variables [2] Debian Wiki, Dot Files [3] Debian Administration, An introduction to run-levels [4] Debian Admin, Debian and Ubuntu Linux Run Levels [5] Linux Information Project (LINFO ), Runlevel Definition [6] LinuxQuestions.org, What are run levels? [7] Dalton Hubble, Bash Configurations Demystified (End)Linux boot process