사용자가 위치하고 있는 현재 디렉토리를 프롬프트상에 표시하는 방법에 대해서 알아보겠습니다.
bash 을 사용한다면 /etc/profile 이나 /etc/bashrc 등의 파일에서 PS1=... 로 시작하는 문장을 볼 수 있습니다.
이부분의 편집을 통해서 프롬프트의 표시내용을 변경할 수 있습니다.
/etc/bashrc 파일을 보면 다음과 같습니다.
------------------------------------------------------
# /etc/bashrc
# System wide functions and aliases
# Environment stuff goes in /etc/profile
# For some unknown reason bash refuses to inherit
# PS1 in some circumstances that I can't figure out.
# Putting PS1 here ensures that it gets loaded every time.
PS1="[\u@\h \W]\\$ "
alias which="type -path"
-------------------------------------------------------
PS1="[\u@ \h \W]\\$ "를 살펴 보면
\u : 사용자
\h : 호스트명
\W : 사용자가 위치하고 있는 경로의 맨 하위 디렉토리입니다.