리눅스에서 너무 긴 명령어 이거나 특정파일을 실행하게 될때 보다 간결, 보다 쉽게 사용하기 위해서,
명령어를 명명하기 위해 사용하는 파일이 .bash_profile 이다.
홈 디렉토리에 있으므로 각 서비스를 실행하는 사용자계정으로 접속해서 ~ (홈 디렉토리) 내에 존재하는 .bash_profile 을 수정해보자.
.> bash_profile 확인
[ontune@localhost ~]$ ls
[ontune@localhost ~]$ pwd
/home/postgres
[ontune@localhost ~]$ ls -arlt
total 20
-rw-r--r--. 1 ontune ontune 231 Nov 25 2021 .bashrc
-rw-r--r--. 1 ontune ontune 18 Nov 25 2021 .bash_logout
drwxr-xr-x. 3 root root 22 Jul 17 17:33 ..
-rw-r--r--. 1 ontune ontune 578 Jul 18 17:11 .bash_profile
drwx------. 2 ontune ontune 104 Jul 18 17:11 .
-rw-------. 1 ontune ontune 2946 Jul 18 17:11 .bash_history
-rw-------. 1 ontune ontune 140 Jul 18 17:11 .psql_history
> vi .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/pgsql/bin
export PATH
위 처럼 기존 PATH 경로에 :/usr/local/pgsql/bin 을 추가함으로써 postgresql을 모든 경로에서 실행 가능할 수 있게 되었다.
Postgresql을 실행하기 위해서는 해당 경로로 직접 이동하여 psql을 실행시켜줬어야 했지만, 이제는 어떠한 경로에서도 postgresql을 실행할 수 있게 되었다.
[ontune@localhost /]$ pwd
/
[ontune@localhost /]$ psql -U ontune
psql (16.3)
Type "help" for help.
ontune=#
이외에도 ENV 설정, alias 설정, export 설정 등 다양하게 설정하여 보다 쉬운 OS 활용이 가능하다.
'OS_Linux&Unix' 카테고리의 다른 글
리눅스에서 너무 긴 명령어 이거나 특정파일을 실행하게 될때 보다 간결, 보다 쉽게 사용하기 위해서,
명령어를 명명하기 위해 사용하는 파일이 .bash_profile 이다.
홈 디렉토리에 있으므로 각 서비스를 실행하는 사용자계정으로 접속해서 ~ (홈 디렉토리) 내에 존재하는 .bash_profile 을 수정해보자.
.> bash_profile 확인
[ontune@localhost ~]$ ls
[ontune@localhost ~]$ pwd
/home/postgres
[ontune@localhost ~]$ ls -arlt
total 20
-rw-r--r--. 1 ontune ontune 231 Nov 25 2021 .bashrc
-rw-r--r--. 1 ontune ontune 18 Nov 25 2021 .bash_logout
drwxr-xr-x. 3 root root 22 Jul 17 17:33 ..
-rw-r--r--. 1 ontune ontune 578 Jul 18 17:11 .bash_profile
drwx------. 2 ontune ontune 104 Jul 18 17:11 .
-rw-------. 1 ontune ontune 2946 Jul 18 17:11 .bash_history
-rw-------. 1 ontune ontune 140 Jul 18 17:11 .psql_history
> vi .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/.local/bin:$HOME/bin:/usr/local/pgsql/bin
export PATH
위 처럼 기존 PATH 경로에 :/usr/local/pgsql/bin 을 추가함으로써 postgresql을 모든 경로에서 실행 가능할 수 있게 되었다.
Postgresql을 실행하기 위해서는 해당 경로로 직접 이동하여 psql을 실행시켜줬어야 했지만, 이제는 어떠한 경로에서도 postgresql을 실행할 수 있게 되었다.
[ontune@localhost /]$ pwd
/
[ontune@localhost /]$ psql -U ontune
psql (16.3)
Type "help" for help.
ontune=#
이외에도 ENV 설정, alias 설정, export 설정 등 다양하게 설정하여 보다 쉬운 OS 활용이 가능하다.