Linux startup file and environment variable location

Source: Internet
Author: User
Linux startup file, set the environment variable location rc. local1,/etc/rc. local system start the Daemon (service) to be loaded and the program to be executed. This file has only one exit0 statement. you can add your own startup program ,... information & nbsp; | & Linux startup file, setting environment variable location rc. local ============================================== 1 ,/ etc/rc. the local system starts the Daemon (service) and programs to be loaded. This file has only one "exit 0" statement. you can add your own startup program, but you must ensure that the final return value is 0. Note: the file cannot contain scripts under the user shell. for example, adding alias ll = "ls-l" is invalid because the execution environment of the file is in the system shell, the system has not yet entered the user shell environment. Linux startup files-[Ubuntu] (/etc/profile,/etc/bashrc ,~ /. Profile ,~ /Bashrc file) ============================================ (1) /etc/profile global (public) configuration. no matter which user, the file will be read during logon. Mac has this file (2)/etc/bashrc Global (public) configuration. When bash shell is executed, the file is read in any way. Mac has this file Ubuntu does not have this file, corresponding to/ect/bash. bashrc (3 )~ /. Bashrc read this file when bash shell is executed in the form of non-login. If it is executed in the form of login, the file will not be read. This file is read at login and every time a new shell is opened .~ /. Bash_profile and ~ /. Bashrc settings are roughly the same, so the former usually calls the latter. (4 )~ /. Bash_profile the file will be read only when bash shell is executed in login mode. This file is only executed once! By default, it sets some environment variables to execute the user's ~ /. Bashrc file .~ /. Bash_profile and ~ /. Bashrc settings are roughly the same, so the former usually calls the latter. Mac has this file (note: Linux contains. bashrc and Mac is. bash_profile) Unbutu does not have this file by default, you can create a new one. (5 )~ /. Bash_login if bash shell is executed in the login mode, read ~ /. Bash_profile. if it does not exist, read ~ /. Bash_login. if the first two do not exist, read ~ /. Profile. (6 )~ /. Profile if bash shell is executed in login mode, read ~ /. Bash_profile. if it does not exist, read ~ /. Bash_login. if the first two do not exist, read ~ /. Profile. In addition, this file will be read when you log on in graphic mode, even if ~ /. Bash_profile and ~ /. Bash_login. Mac does not have this file by default. you can manually create this file (7 )~ /. Bash_logout, which is in the longin format, will be read. That is to say, when you log out in text mode, the file will be read, and when you log out in graphic mode, the file will not be read. Below is the local machine (Ubuntu) examples. when logging on in graphical mode, read:/etc/profile and ~ sequentially ~ /. Profile2. after logging on to the graphical mode, read:/etc/bash. bashrc and ~ in sequence when you open the terminal ~ /. Bashrc3. when logging on in text mode, read:/etc/bash. bashrc,/etc/profile and ~ in sequence ~ /. Bash_profile4. there are two cases from another user su to this user: (1) If the-l parameter (or-parameter, -- login parameter) is included, for example, su-l username, bash is lonin, which reads the following configuration files in sequence:/etc/bash. bashrc,/etc/profile and ~ /. Bash_profile. (2) If the-l parameter is not included, bash is non-login, which reads:/etc/bash. bashrc and ~ sequentially ~ /. Bashrc5. when logging out, or the user logging out of su, if it is in longin mode, bash will read :~ /. Bash_logout6. when you execute a custom shell file, if you use the "bash-l a. sh" method, bash will read the rows:/etc/profile and ~ /. Bash_profile. if other methods are used, such as bash. sh ,. /. sh, sh. sh (this does not belong to bash shell), it will not read any of the above files. 7. in the above example ~ /. Bash_profile. if the file does not exist, read ~ /. Bash_login. if the first two do not exist, read ~ /. Profile.
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.