본문 바로가기

L I N U X

/etc/bash.bashrc /root/.bash_profile 의 차이

/etc/bash.bashrc /root/.bash_profile의 차이를 찾던 중에 볼만한 글이 있어서 스크립한다
한마디로 로그인시와 비로그인시 활성화되는 차이점 이다 
시간 되면 번역을 좀 해 놔야되겠다 



https://wiki.archlinux.org/index.php/Bash 

Configuration file overview

  • /etc/profile
  • ~/.bash_profile
  • ~/.bash_login
  • ~/.profile
  • /etc/bash.bashrc (Non-standard: only some distros, Arch included)
  • ~/.bashrc
  • ~/.bash_logout

An overview of the commonly used configuration files:

/etc/profile

/etc/profile is sourced by all Bourne-compatible shells upon login. It sets up an environment upon login and loads application-specific (/etc/profile.d/*.sh) settings.

.profile

This file is read and sourced by bash when an interactive login shell is started.

.bashrc

The file ~/.bashrc is read and sourced by bash when a non-login interactive shell is started, for example, when you open a virtual console from the desktop environment. This file is useful for setting up a user-specific shell environment.

Configuration file sourcing order

These files are sourced by bash in different circumstances.

  • if interactive + login shell → /etc/profile then the first readable of ~/.bash_profile~/.bash_login, and ~/.profile
    • Bash will source ~/.bash_logout upon exit.
  • if interactive + non-login shell → /etc/bash.bashrc then ~/.bashrc
  • if login shell + legacy mode → /etc/profile then ~/.profile

But, in Arch, by default:

  • /etc/profile (indirectly) sources /etc/bash.bashrc
  • /etc/skel/.bash_profile which users are encouraged to copy to ~/.bash_profile, sources ~/.bashrc

which means that /etc/bash.bashrc and ~/.bashrc will be executed for all interactive shells, whether they are login shells or not.

Examples of the user dotfiles can be found in /etc/skel/.