ETC

su - 와 su의 차이

MuGrammer 2011. 8. 22. 12:39

생각없이 사용하긴 했지만 몰랐던 것 (1)

su (switch user) 명령어를 사용할 때 [-]하이픈의 용도.


[-] 을 붙이게 되면 변경된 user 의 profile을 가져오게 되고 붙이지 않으면 현재 user profile을 불러오게 된다.



      If the - option is specified, the new shell starts up as if the new
      user had initiated a new login session.  Exceptions are as follows:
        +  The HOME variable is reset to the new user's home directory.
        +  If the new user name is root, the path and prompt variables are
           reset:
           PATH=/usr/bin:/usr/sbin:/sbin
           PS1=#
           For other user names:
           PATH=/usr/bin
           PS1=$
        +  The TERM variable is retained.
        +  The rest of the environment is deleted and reset to the login
           state.  However, the login files are normally executed anyway,
           usually restoring the expected value of PATH and other variables.
      If the - option is omitted, the new shell starts as if a subshell was
      invoked.  Exceptions are as follows:
        +  If the new user name is root, the path and prompt variables are
           reset:
           PATH=/usr/bin:/usr/sbin:/sbin
           PS1=#
        +  The previously defined HOME and ENV environment variables are
           removed.
        +  The rest of the environment is retained.
        If the shell specified in /etc/passwd is /usr/bin/sh, su sets the
        value of parameter 0 in the new shell (referenced as $0) to su.  If
        the - option of the su command is specified, su sets parameter 0 to
        -su.
        If the shell specified in /etc/passwd is not /usr/bin/sh, su sets
        the value of parameter 0 in the new shell to shellname.  If the -
        option of the su command is specified, su sets parameter 0 to
        -shellname.  For example, if the Korn shell is invoked, the value of
        shellname will be either ksh or -ksh.
        By comparison, the login command always sets parameter 0 to
        -shellname.
반응형

'ETC' 카테고리의 다른 글

SVN .. 적응하기 어렵다  (0) 2011.08.26
WAS 관련 참고 사이트 및 블로그(..ing)  (0) 2011.08.25
WebLogic 설치  (0) 2011.08.11
[HP-UX] java 버전 확인  (0) 2011.08.11
ALBD network connection errors in log on the client machine  (0) 2011.07.22