실행순서
1) profile -> 2 ) bash_profile -> 3) bashrc
1) /etc/profile
login shell을 bash shell 로 실행하는 모든 user에게 적용.
직접 편집하는 것보다 /etc/profile.d에 shell script 작성
history시간등록 등~
해당파일 안의 shell script
if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`/usr/bin/id -u`
UID=`/usr/bin/id -ru`
fi
USER="`/usr/bin/id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
done
2) .bash_profile
login 쉘을 배시쉘로 실행하는 모든 user에게 적용
bash shell을 실행하는 모든 시스템에 적용할 함수나 별칭(aliases) 추가
alias 'vi'='vim' 등과같은 ~
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
3)/etc/bashrc
User에게 적용할 함수나 별칭 추가
# /etc/bashrc
# System wide functions and aliases
# Environment stuff goes in /etc/profile
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
# are we an interactive shell?
if [ "$PS1" ]; then
if [ -z "$PROMPT_COMMAND" ]; then
case $TERM in
xterm*|vte*)
if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
elif [ "${VTE_VERSION:-0}" -ge 3405 ]; then
PROMPT_COMMAND="__vte_prompt_command"
else
PROMPT_COMMAND='printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
fi
;;
screen*)
if [ -e /etc/sysconfig/bash-prompt-screen ]; then
PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
else
PROMPT_COMMAND='printf "\033k%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"'
fi
;;
*)
[ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
;;
esac
fi
'Linux&Ubuntu > 서버' 카테고리의 다른 글
[linux] hostname 변경 (0) | 2021.11.15 |
---|---|
[linux]부팅시 자동 실행 (0) | 2021.11.04 |
[linux]swap 메모리 개념 및 설정,삭제 (0) | 2021.10.31 |
[linux]심볼릭 링크와 하드링크의 차이점 (0) | 2021.10.27 |
[linux]inode 상태 확인 및 삭제 (0) | 2021.10.26 |