Linux in order to load the system environment variables and environment variables

System environment variables :

/ Etc / profile: This document presupposes several important variables, such as PATH, USER, LOGNAME, MAIL, INPUTRC, HOSTNAME, HISTSIZE, umask, and so on.

/ etc / bashrc: This file is the main default umask and PS1. The PS1 is when we knock on command, in front of a string of characters, such as [ root @ localhost  ~] #,

User environment variables :

.bash_profile: the definition of a personal path and file name of the user environment variable. Each user can use the file input information specific to shell their own use, when a user logs in, the file is only executed once . (Executive .bashrc script in this file)

.bashrc: This file contains specific to your shell bash information, when and login every time you open a new shell, which the file is read . For example alias you can be user-defined or user-defined variables wrote this file.

.bash_history: command history with.

.bash_logout: When you exit the shell, it will execute the file. You can put some cleanup work put in this file.

centos6 boot process:

1, kernel boot

When the computer is powered on, first the BIOS POST, the BIOS boot device in accordance with the set (typically a hard disk) to start. Followed by the program on the grub boot device begins to boot Linux, the boot program after successful completion of the task of guiding, Linux to take over from their hands the control of the CPU, then the CPU starts executing the code of Linux kernel image, the Linux boot process began . Also known as the beginning of a kernel boot, the kernel boot process is actually very complex, it is when we have a black box , because it is the Linux kernel to do a series of work, and finally loaded kernel calls init program, bringing the kernel boots work is complete. Next to the protagonist init.

2, run init

The init process is the starting point of all processes of the system, you can compare it to our ancestors all processes of the system, not the process, the system will not start any process. init main function is to prepare the implementation of the software environment, including the system's host name, network settings, language, file system format and start other services and so on. And all the action will be by init configuration file / etc / inittab to plan, and within inittab there is a very important set of content, and that is the default runlevel (boot run level). Let's look at run level Run level, Linux is set to run level is specified by the system to use a different service to start, let's use a different Linux environment. We take a look inside this file inittab level of support.

# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
id:3:initdefault:

 

inittab configuration file format and the old versions before CentOS5 or older than the version changed substantially. Runlevels total of seven levels, 0 represents off and 1 represents a single user, there is no network 2 command line level 3 command levels (mostly servers use this level) , the retention level 4, level 5 is a graphical, 6 restart. This file is in addition to the last line, the other is a comment line, that last line is the key, which is used to specify the server to run what level, where in addition to other things you can set 2,3,5 level can not be set. In the front section of the file, you can see a lot of reference to a line in the configuration file, all configuration files are in / etc / init / directory.

3, system initialization

System initialization, is to perform various configuration files / etc / init / under . inittab configuration file such a line "System initialization is started by /etc/init/rcS.conf" That system initialization will be executed first and the profile /etc/init/rcS.conf another line "exec / etc /rc.d/rc.sysinit "so, the focus has shifted to the rc.sysinit file, it will do the following: activating the swap partition, check the disk, load the hardware module and a number of other priority tasks. When rc.sysinit program is finished, init will return to the next step, we went to the /etc/init/rc.conf, in this configuration file, the most critical behavior "exec /etc/rc.d/rc $ RUNLEVEL "the $ RUNLEVEL in the / etc / inittab defined (bottom that line), with a Ming / etc / inittab, for example, represents a $ RUNLEVE = 3, so at this time will perform the" /etc/rc.d / rc 3 "at this time is actually the script under /etc/rc.d/rc3.d/ gave executed, then /etc/rc.d/rc.local will be executed, usually we will boot command to start the implementation of the decentralization of the script . Service executed, system initialization is complete. Next, the establishment of the terminal.

4, the establishment of the terminal

It is established by the terminal profile /etc/init/tty.conf, /etc/init/serial.conf and / etc / sysconfig / init like profile done. In operation level are 2,3,4,5 mingetty program will run respawn, mingetty program can open the terminal, setting mode. At the same time it will display a text login screen, the interface is what we often see the login screen, in the login screen will prompt the user to enter a user name, user input and the user will be passed as a parameter to validate user login identity.

5, the user login system

For graphical user run level 5, their log in through a graphical login screen. After a successful login can go directly to KDE, Gnome and other window manager. The paper stresses the situation or text login: When we see mingetty login screen, we can enter a user name and password to log in the system.

Linux account verification process is login, login will receive a user name mingetty came as the username parameter. Then login user name will be analyzed: If the username is not root, and there is "/ etc / nologin" file, login nologin will output the contents of the file, and then exit. This prevents non-root user login time is usually used for system maintenance. Only "/ etc / securetty" registered in the terminal only allows root user login, if the file does not exist, the root can log on any terminal. "/ Etc / usertty" file is used to make additional access restrictions on users, if the file does not exist, there are no other restrictions.

After analyzing the user name, login will search for "/ etc / passwd" and "/ etc / shadow" to verify the account password and other settings, such as: What are the main directory, which shell to use. If no home directory, the default directory is the root; shell if not specified, the default is "/ bin / bash".

After the login procedure is successful, the corresponding terminal in output last logged (recorded in "/ var / log / lastlog" in), and check whether the user has new messages (in the "/ usr / spool / mail / " the application user name directory). Then start setting various environment variables: For bash, the system first looks for "/ etc / profile" script file and execute it ; and then if there is user's home directory in the  .bash_profile file, you execute it (there is executed in this file. bashrc script) , and in these documents may call the other configuration files, after all the configuration file is executed, various environment variables are also located well, then there will be the familiar command line prompt, this whole start process is over.

 

Guess you like

Origin www.cnblogs.com/tiandi/p/11317083.html