.profile과 .bash_profile의 차이점은 무엇이며 언제 구성합니까? (Mac) [중복]

중복 가능성 :
.bashrc와 .bash_profile의 차이점

무슨 사이의 차이점 .profile.bash_profile, 때 당신은 어떻게 구성해야합니까?

.bash_profile,를 구성해도 여전히 구성해야 .profile합니까?



답변

bash기본 쉘 이라고 가정하면 차이점은 bash매뉴얼 페이지 ( man bash)에 설명되어 있습니다 .

   When bash is invoked as an interactive login shell, or as  a  non-interac-
   tive  shell  with the --login option, it first reads and executes commands
   from the file /etc/profile, if that file exists.  After reading that file,
   it  looks  for  ~/.bash_profile,  ~/.bash_login,  and  ~/.profile, in that
   order, and reads and executes commands from the first one that exists  and
   is readable.  The --noprofile option may be used when the shell is started
   to inhibit this behavior.

매뉴얼 페이지에는 POSIX-shell 호환 모드에 대한 자세한 내용 .profile이 나와 있습니다. 모든 세부 사항은 전체 맨 페이지 섹션을 읽으십시오.


답변

를 구성하면을 구성 .bash_profile할 필요도 없습니다 .profile.

나는 별명과 명령을 그대로 유지 .profile하여 무언가를 엉망으로 만들면 (MacPorts와 같이) .profile수정하는 다른 응용 프로그램이나 다른 응용 프로그램에서 시스템에 영향을 미치지 않고 항상 삭제할 수 있음을 알고 있습니다 .bash_profile.

를 사용하려면 파일을 읽을 수 있도록 .profile행을 포함해야 할 수도 있습니다 (Ned Deily의 답변 참조).source ~/.profile.bash_profile.profile


답변

.profile은 일반적인 쉘 프로세스가있을 때 bash에 의해 실행됩니다 (예 : 터미널 도구 열기). .bash_profile은 로그인 쉘을 위해 bash에 의해 실행되므로, 예를 들어 원격으로 컴퓨터에 telnet / ssh를 연결할 때입니다. 예를 들어 컴퓨터에 원격으로 ssh하면 (X 터미널을 연다 고 가정) 처음에는 .bash_profile이 실행됩니다. 해당 XTerminal에 “xterm”을 입력하고 다른 X 터미널을 생성하면 XTerminal의 두 번째 인스턴스에 대해 .profile이 실행됩니다. 파일은 홈 디렉토리 (~)에 있습니다. 기본적으로 착각하지 않으면 둘 다 ~ / .bashrc를 실행하여 로그인 쉘과 비 로그인 쉘 모두에 공통 설정 / 변수를 구성하도록 편집 할 수 있습니다 (예 : PATH 설정, 일부 별칭 / 바로 가기 등).


답변

빠르고 간단한 설정 (복잡한 것을 원하지 않는 곳)의 경우 ~ / .profile에있는 모든 것을 구성하면됩니다. .bash_login 또는 .bash_profile;에 대해 더 이상 배우지 못할 수도 있습니다.)

나는 OS X에서도 .bash_profile 또는 .bash_login을 필요로하지 않았으며 .profile 만 사용하지만 마일리지는 다를 수 있습니다 …