sklass의 s-class 프로그래밍 blog

Interactive Shell & Login Shell 본문

shell

Interactive Shell & Login Shell

sklass 2021. 8. 21. 18:14

현재 사용자의 상태에 따라서 shell이 interactive한지 login인지를 판단하고, 이에 맞는 실행파일들을 실행시키게 되어있습니다. 이번 포스트에서는 각 shell들을 설명하겠습니다.

 

Interactive Shell

Shell 이 실행되는 환경을 두가지로 나누어 볼 수 있습니다. 사용자로 부터 프롬프트를 통해 직접 명령을 입력받아 실행시키는 interactive shell 과 작성한 script 파일을 실행하는것과 같은 non-interative shell 입니다.

 

Login Shell

terminal을 열거나 ssh, putty를 사용하는 경우를 모두 Login Shell이라고 합니다.

 

시작시 /etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile 순서로 파일을 읽어들여 실행합니다. 보통 /etc/profile 에서는 . ( source 명령 ) 을 이용해 /etc/bash.bashrc 를 읽어들이고 ~/.profile 에서는 ~/.bashrc 파일을 읽어들입니다.

 

logout ( 또는 exit ) 시에 ~/.bash_logout 파일을 실행합니다.

 

 

MacOS 기본 Shell

MacOS의 기본 shell은 zsh로, interactive 인지 login인지에 따라 실행하는 startup file이 다릅니다. 아래 사진이 어떤 상황에서 어떤 startup file을 어떤 순서로 읽는지(source) 설명합니다.

zsh startup files 실행 순서

보통 MacOS에서 terminal을 켜면, Interactive Login Shell 입니다.

'shell' 카테고리의 다른 글

rsync  (0) 2021.10.12
linux tee 명령어  (0) 2021.09.04
Visual Studio Code에서 code 명령어 영구적으로 설정하는 법(MacOS)  (0) 2021.08.21
.bash_profile VS .zshrc  (0) 2021.08.21
iTerm2 + zsh + oh my zsh  (0) 2021.08.18