The difference between Linux files ~/.BASHRC and ~/.bash_profile and/ETC/BASHRC and/etc/profile | Order of loading profiles after user logon

Source: Internet
Author: User

    • Turn from 9206151
    • File Description:
      • /ect/profile
        • This file sets the environment information for each user of the system, and the file is executed the first time the user logs on. and collects the shell settings from the configuration file of the/ETC/PROFILE.D directory.
      • /etc/bashrc
        • Execute this file for each user running the bash shell. When the bash shell is opened, the file is read.
      • ~/.bash_profile
        • Each user can use the file to enter shell information dedicated to their own use, and when the user logs in, the file executes only once! By default, he sets some environment variables to execute the ~/.BASHRC file.
      • ~/.bashrc
        • The file contains bash information dedicated to the user's Bash shell, which is read when it is logged in and every time a new shell is opened.
      • ~/.bash_logout
        • Executes the file each time it exits the system (exiting the bash shell).

    • In addition, the variables set in/etc/profile (global) can act on any user
    • The variables set in ~/.BASHRC and so on (local) can only inherit the variables in/etc/profile, they are "parent-child" relationships.

    • The order in which the configuration files are loaded after the user logs in:
  1. /etc/profile-------->/etc/profile.d/*.sh
  2. ~/.bash_profile-------->~/.BASHRC---------->/ETC/BASHRC
  • Description
    • Bash executes the/etc/profile script first, and the/etc/profile script executes the/etc/profile.d/*.sh in turn first
    • Bash then executes the ~/.bash_profile script, the ~/.bash_profile script executes the ~/.BASHRC script, and the ~/.BASHRC script executes the/ETC/BASHRC script
    • At this point, all environment variables and initialization settings have been loaded and completed.
    • Bash then calls Terminfo and INPUTRC to complete the settings for Terminal properties and keyboard mappings, respectively.

The difference between Linux files ~/.BASHRC and ~/.bash_profile and/ETC/BASHRC and/etc/profile | Order of loading profiles after user logon

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.