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

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. 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

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.