2014년 7월 6일 일요일

Linux 에서 Path 지정하기 (Original page http://www.cyberciti.biz/faq/unix-linux-adding-path/)

UNIX / Linux: Set your PATH Variable Using set or export Command


Finding out your current path

 
echo "$PATH"
 
OR
 
printf "%s\n" "$PATH"
 
How do I modify my path?
Bash, Sh, Ksh shell syntax to modify $PATH
If you are using bash, sh, or ksh, at the shell prompt, type:
## please note 'PATH' is CASE sensitivity and must be in UPPERCASE ##
export PATH=$PATH:/path/to/dir1
export PATH=$PATH:/path/to/dir1:/path/to/dir2
 
OR
## please note 'PATH' is CASE sensitivity and must be in UPPERCASE ##
PATH=$PATH:/path/to/dir1; export PATH
 
Tcsh or csh shell syntax to modify $PATH
If you are using tcsh or csh, shell enter:
 ## please note 'path' is case sensitivity and must be in lowercase ##
set path = ($path /path/to/dir1)
set path = ($path /path/to/dir1 /path/to/dir2)
 
OR
## please note 'PATH' is CASE sensitivity and must be in UPPERCASE ##
setenv PATH $PATH:/path/to/dir1
setenv PATH $PATH:/path/to/dir1:/path/to/dir2
 
To make these changes permanent, add the commands described above to the end of your~/.profile file for sh and ksh shell, or ~/.bash_profile file for bash shell:
## BASH SHELL ##
echo 'export PATH=$PATH:/usr/local/bin'  >> ~/.bash_profile
 
KSH/sh shell user try:
## KSH / SH SHELL ##
echo 'export PATH=$PATH:/usr/local/bin'  >> ~/.profile
 
In this final example add /usr/local/bin/ and /scripts/admin/ to your path under csh / tcsh shell, enter:
 
set path = ($path /usr/local/bin /scripts/admin)
 
OR
 
setenv PATH $PATH:/usr/local/bin:/scripts/admin
 
To make these changes permanent, add the commands described above to the end of your~/.cshrc file:
 
echo 'set path = ($path /usr/local/bin /scripts/admin)'  >> ~/.cshrc
 
OR
 
echo 'setenv PATH $PATH:/usr/local/bin:/scripts/admin'  >> ~/.cshrc
 
To verify new path settings, enter:
$ echo $PATH

댓글 없음:

댓글 쓰기