"Profile bashrc 실행 순서"의 두 판 사이의 차이

37번째 줄: 37번째 줄:
*리눅스 → ~/.bash_profile → ~/.bashrc → /etc/bashrc
*리눅스 → ~/.bash_profile → ~/.bashrc → /etc/bashrc


이것을 각 파일의 마지막에 코드를 추가했을 때 기준으로 실행순서를 정리하면 맨 위에 정리한 바와 같게 된다.
이것을 각 파일의 마지막에 코드를 추가했을 때 기준으로 실행순서를 정리하면, 위 문단에서 설명한 바와 같게 된다.
* /etc/profile.d/test.sh → /etc/profile
* /etc/profile.d/test.sh → /etc/profile
* /etc/bashrc → ~/.bashrc → ~/.bash_profile
* /etc/bashrc → ~/.bashrc → ~/.bash_profile

2012년 3월 30일 (금) 17:30 판

  • profile bashrc bash_profile 실행 순서

1 기본 설정

기본 설정에서 실행 순서는 다음과 같다.

  • 각 파일의 맨 아래 부분에 실행 코드를 추가할 때의 기준이다.
  • 특별히 코드를 변경하지 않았다면 이 순서대로 실행될 것이다.
  1. /etc/profile.d/test.sh
  2. /etc/profile
  3. /etc/bashrc
  4. ~/.bashrc
  5. ~/.bash_profile

2 분석

~/.bash_profile에 다음과 같은 내용이 있다.

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

→ ~/.bashrc 가 있으면 그것을 실행시킨다.

~/.bashrc 에 다음과 같은 내용이 있다.

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

→ /etc/bashrc가 있으면 그것을 실행시킨다.

실행파일의 호출 순서를 정리하면 다음과 같다. (OS는 /etc/profile과 ~/.bash_profile 2개를 순서대로 호출할 뿐인데, 각 파일이 내부적으로 다른 파일을 호출하는 것이다.)

  • 리눅스 → /etc/profile → /etc/profile.d/test.sh
  • 리눅스 → ~/.bash_profile → ~/.bashrc → /etc/bashrc

이것을 각 파일의 마지막에 코드를 추가했을 때 기준으로 실행순서를 정리하면, 맨 위 문단에서 설명한 바와 같게 된다.

  • /etc/profile.d/test.sh → /etc/profile
  • /etc/bashrc → ~/.bashrc → ~/.bash_profile

3 참고 자료

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}