.bashrc 와 .bash_profile의 차이가 무엇인지요?

k9252의 이미지

.bashrc와 .bash_profile을 보면 2개가 비슷하게 작성이 되어있는데요..

그 차이점은 무엇인지요?

제가 알기로는 path등은 .bash_profile에 등록하는것으로 아는데..

.bashrc에도 등록해도 되는지요??

그 상관관계에 대해서 자세한 설명 부탁드립니다.

cdpark의 이미지

.bashrc는 bash이 실행될 때마다 수행되고, .bash_profile은 bash이 login shell로 쓰일 때(즉 처음 login할 때)에 수행됩니다.

child shell은 부모로부터 환경변수를 이어받으니 .bashrc에서 따로 PATH를 설정해 줄 필요는 없습니다만... GUI 환경에서 새 terminal을 여는 경우에는 login shell로 처리되지 않으므로 주의가 필요합니다.

lacovnk의 이미지

# ~/.bash_profile: executed by bash(1) for login shells.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

umask 022

# the rest of this file is commented out.

# include .bashrc if it exists

if [ -f ~/.bashrc ]; then
    source ~/.bashrc
fi
(이하생략)

이렇게 되어있군요 :)