'.bash_profile'에 해당되는 글 1건

  1. 2010.03.04 bash 환경설정 - 모든 유저를 한번에 설정하기
Linux2010.03.04 10:54
로그인 쉘을 위해 실행되는
시스템 전역 초기화 파일인 /etc/profile을 수정하면 모든 사용자에게 적용이 될것으로 예상된다.

debian 도움말에는
/etc/bash.bashrc가 존재하고 이녀석은 login shell
/etc/profile은 interactive shell에 적용된다고 되어있다.

그런데 login shell과 per-interative-shell의 차이가 멀까?

$ man bash
       In  addition to the single-character shell options documented in the description of the set builtin command, bash
       interprets the following options when it is invoked:

       -c string If the -c option is present, then commands are read from string.  If  there  are  arguments  after  the
                 string, they are assigned to the positional parameters, starting with $0.
       -i        If the -i option is present, the shell is interactive.
       -l        Make bash act as if it had been invoked as a login shell (see INVOCATION below).

       A login shell is one whose first character of argument zero is a -, or one started with the --login option.

       An interactive shell is one started without non-option arguments and without the -c option whose  standard  input
       and  error  are both connected to terminals (as determined by isatty(3)), or one started with the -i option.  PS1
       is set and $- includes i if bash is interactive, allowing a shell script or a startup file to test this state.

              The bash executable
              The systemwide initialization file, executed for login shells
              The personal initialization file, executed for login shells
              The individual per-interactive-shell startup file
              The individual login shell cleanup file, executed when a login shell exits
              Individual readline initialization file

[링크 : http://linux.die.net/man/1/bash]
[링크 : http://www.lq.org/questions/linux-general-1/difference-between-normal-shell-and-login-shell-14983/]

FC6에서 내용확인
$ cat /etc/bashrc
 # /etc/bashrc

 # System wide functions and aliases
 # Environment stuff goes in /etc/profile

 # By default, we want this to get set.
 # Even for non-interactive, non-login shells.

$ cat /etc/profile
# /etc/profile

# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc

아무튼, interactive shell은 stdin와 stderr(잉? 왜 stdout이 아니지?)이 둘다 연결된 셸로
우리가 일반적으로 사용하는 녀석으로 생각된다.
결론은 login shell보다는 interactive shell용 환경변수 파일에 alias 등을 지정하는게 좋을듯 하다.
Posted by 구차니

댓글을 달아 주세요