Analysis of/etc/profile,/etc/bashrc, ~ in linux ,~ /. Bash_profile ,~ /. Bashrc file

Source: Internet
Author: User
Analysis of/etc/profile,/etc/bashrc, ~ in linux ,~ /. Bash_profile ,~ /. Bashrc file/etc/profile: This file sets the environment information for each user in the system. when the user logs on for the first time, the file is executed. and from/etc/profile. d Directory configuration file to collect shell settings...
Analysis of/etc/profile,/etc/bashrc, ~ in linux ,~ /. Bash_profile ,~ /. Bashrc file/etc/profile: This file sets the environment information for each user in the system. when the user logs on for the first time, the file is executed. and from/etc/profile. the configuration file in the d directory collects shell settings. /etc/bashrc: execute this file for every user running bash shell. when the bash shell is opened, the file is read. www.2cto.com ~ /. Bash_profile: each user can use this file to input the shell Information dedicated to their own use. when a user logs on, this file is only executed once! By default, it sets some environment variables to execute the user's. bashrc file .~ /. Bashrc: This file contains the bash information dedicated to your bash shell. when you log on and every time you open a new shell, this file is read. www.2cto.com ~ /. Bash_logout: execute this file every time you exit the system (exit bash shell). In addition, the variable (global) set in/etc/profile can act on any user, and ~ The variables (local) set in/. bashrc and so on can only inherit the variables in/etc/profile. they are "parent-child" relationships .~ /. Bash_profile is interactive and login to run bash ~ /. Bashrc is the interactive non-login mode that enters bash. Generally, the two settings are roughly the same, so the former usually calls the latter. Several bash initialization files-[Ubuntu] (1)/etc/profile global (public) configuration. no matter which user, the file will be read during login. This file does not exist in www.2cto.com (2)/ect/bashrc Ubuntu, which corresponds to/ect/bash. bashrc is also a global (public) bash execution that reads the file in any way. (3 )~ /. Profile if bash 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. In addition, this file will be read when you log on in graphic mode, even if ~ /. Bash_profile and ~ /. Bash_login. (4 )~ /. Bash_login if bash 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. (5 )~ /. Bash_profile Unbutu does not have this file by default. you can create a new file. This file is read only when bash is executed in the form of login. This configuration file is usually configured to read ~ /. Bashrc. (6 )~ /. Bashrc read this file when bash is executed in the form of non-login. If it is executed in the form of login, the file will not be read. (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. Under www.2cto.com, there are several examples on the local machine: 1. when logging on in graphic mode, read:/etc/profile and ~ sequentially ~ /. Profile 2. after logging on to the graphical mode, read:/etc/bash. bashrc and ~ in sequence when the terminal is opened ~ /. Bashrc 3. when logging on in text mode, read:/etc/bash. bashrc,/etc/profile and ~ in sequence ~ /. Bash_profile 4. 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 ~ /. Bashrc 5. when logging out, or the user logging out of su, if it is in longin mode, bash will read :~ /. Bash_logout 6. 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. Differences between profile and bashrc in linux/ect/root/home/myuser profile in the related directory of Ubuntu. profile. profile bash. bashrc. bashrc. bashrc profile. d Ora directory/ect // root/home/myuser profile bashrc. bashrc profile. d profile. d www.2cto.com description: myuser is the user you have added and created. it cannot be found online for half a day, so it can only be compared. To identify the differences between bashrc and profile, you must first understand what is interactive shell and non-interactive shell, and what is login shell and non-login shell. In interactive mode, shell waits for your input and runs the command you submit. This mode is called Interactive because shell interacts with users. This mode is also very familiar to most users: logon, command execution, and logout. When you sign back, shell is terminated. Shell can also run in another mode: non-interactive mode. In this mode, shell does not interact with you, but reads commands stored in files and runs them. When it reads the end of the file, shell is terminated. Both bashrc and profile are used to save the user's environment information. bashrc is used for interactive non-loginshell, while profile is used for interactive login shell. Many bashrc and profile files exist in the system. the file/etc/pro is used to set environment information for each user in the system. when the first user logs on, the file is executed. and from/etc/profile. the configuration file in the d directory collects shell settings. www.2cto.com/etc/bashrc: run this file for every user running bash shell. when the bash shell is opened, the file is read. Some linux versions have no bashrc files in the/etc directory. ~ /. Pro each user can use this file to input shell Information dedicated to their own use. when a user logs on, this file is only executed once! By default, it sets some environment variables and then executes the user's. bashrc file .~ /. Bashrc: This file contains bash information specific to a user's bash shell. when the user logs on and opens a new shell each time, the file is read. in addition, the variables (global) set in/etc/profile can act on any user ~ /. The variables (local) set in bashrc and so on can only inherit the variables in/etc/profile. they are "parent-child" relationships. A netizen concluded as follows: www.2cto.com/etc/profile,/etc/bashrc is the global environment variable setting of the system ~ /. Profile ,~ /. Set the private environment variable in the bashrc user's home directory. when you log on to the system and obtain a shell process, in step 1, the system reads the global environment variable configuration file/etc/profile, and then reads additional settings documents, such as/etc/profile, based on the content. d and/etc/inputrc 2. then, read from the home directory according to different user accounts ~ /. Bash_profile. if it cannot be read, it will be read ~ /. Bash_login, which cannot be read before it can be read ~ /. Profile. the settings of these three documents are basically the same. Reading has a priority relationship. 3. then reading the files based on the user account ~ /. Bashrc as ~ /. Profile and ~ /. All the differences between bashrc and bashrc have the customization function ~ /. Profile can set the user's proprietary path, environment variables, and so on. it can only be executed once during login ~ /. Bashrc is also a user-specific configuration document. you can set the path and command alias. every time you run a shell script, it will be used by huhao1989
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.