歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux服務器

關於Linux系統下PATH設置方法

假設你要執行的程序路徑在 /usr/my下
 
   export PATH=/usr/my:$PATH

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
export PATH=/usr/my:$PATH


 
  保存退出!
 
  [root@stroller root]# source .bashrc
 
  完整例子:
 
  [root@stroller root]# vi .bashrc
 
   # .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

 


 
  然後在 fi 後面加下面語句:
 
  export PATH=/root:$PATH
 
  加完後的 .bashrc 內容為:
 
   # .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

export PATH=/root:$PATH

 


 
  //在命令行下輸入 source .bashrc 執行 .bashrc 生效。
 
  [root@stroller root]# source .bashrc
 
  //查看PATH值:
 
  [root@stroller root]# echo $PATH
 

Copyright © Linux教程網 All Rights Reserved