Ubuntu 20.04 에서 terminal을 작업할 때는 텍스트에 색상이 부여되어있어 가독성이 높습니다.
![](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
하지만 터미널에서 ssh로 서버에 원격접속하였을 때, 무색의 스타일로 접속되어 가독성이 매우 떨어집니다.
![](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
이 무색무취의 터미널의 스타일 변경을 시도해보았습니다.
먼저, ssh 원격 접속된 터미널 내에서 보편적으로 /home/username/ 디렉토리에 .bashrc라는 파일이 있습니다.
( ls로는 .file은 보이지 않기 때문에 ls -a 라는 명령어를 통해서 확인할 수 있습니다. )
우선 사진의 초록색, 파란색 부분의 프롬프트인 username@hostname : ~working_directory $ 부분을 색상 변경 해보겠습니다.
vi .bashrc
i
PS1='\[\033[0;32m\]\u@\h:\[\033[0;34m\]\w\[\033[0m\]\$ '
esc > :wq > enter
source .bashrc
- vi 에디터로 .bashrc 파일을 수정하러 들어갑니다.
- i를 눌러 insert mode로 진입합니다.
- 첫번째 줄 혹은 원래 있던 PS1에 대한 설정을 확인하고, /u@/h: 앞에 초록색 컬러, /w에 대해 파란색 컬러, 그 뒤는 다시 흰색으로 초기화하는 내용으로 설정해줍니다.
- esc를 눌러 insert mode를 빠져나오고, 파일 저장을 위해 :wq를 누른 후, enter를 눌러 파일을 빠져나옵니다.
- source .bashrc 를 통해서 설정한 변수를 시스템에 적용해줍니다.
![](http://t1.daumcdn.net/tistory_admin/static/images/no-image-v1.png)
Color Code
- Black 0;30
- Blue 0;34
- Green 0;32
- Cyan 0;36
- Red 0;31
- Purple 0;35
- Brown 0;33
참고 사이트
How can you change the color of your shell prompt on Linux?
Answer (1 of 2): You can change the color of your shell prompt on Linux by modifying the PS1 environment variable. PS1 contains the prompt string, and you can include escape sequences in it to specify colors. Here's an example: 1. Open your terminal applic
www.quora.com
더 디테일한 정보
Bash Shell PS1: 10 Examples to Make Your Linux Prompt like Angelina Jolie
Bash Shell PS1: 10 Examples to Make Your Linux Prompt like Angelina Jolie by Ramesh Natarajan on September 8, 2008 In the previous article, we discussed about Linux environment variables PS[1-4] and PROMPT_COMMAND. If used effectively, PS1 can provide valu
www.thegeekstuff.com
*** 사실 가장 쉽고 빠른 방법은 로컬의 우분투 linux terminal에 접속한 후, bashrc 파일에 있는 color에 대한 설정값들을 복사해서 ssh 접속한 서버의 bashrc파일로 붙여넣기하는 것입니다...ㅎㅎ
로컬 .bashrc 파일의 color관련 설정값들
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
'Programming > linux' 카테고리의 다른 글
리눅스 터미널에서 동일한 폴더 내의 파일명 일괄 변경하기 (0) | 2024.03.23 |
---|---|
[Linux 리눅스] 대용량 이미지 데이터셋 GUI에서 빠르게 탐색하는 방법: gthumb (0) | 2023.12.21 |
Window에 Linux설치 - 멀티부팅 방법 (Ubuntu 20.04 LTS Desktop) + 그래픽드라이브/듀얼모니터 인식 안됨 문제 해결 (2) | 2023.12.19 |
리눅스 컴퓨터에 외장하드 인식이 안될 때 해결법 (0) | 2023.12.18 |
aihubshell API key로 데이터 다운로드 받기 (0) | 2023.12.14 |