假设你要执行的程序路径在 /usr/my下
<ccid_nobr>
<ccid_code>export PATH=/usr/my:$PATH# .bashrc# User specific aliases and functionsalias rm='rm -i'alias cp='cp -i'alias mv='mv -i'# Source global definitionsif [ -f /etc/bashrc ]; then. /etc/bashrcfiexport PATH=/usr/my:$PATH
保存退出!
[root@stroller root]# source .bashrc
完整例子:
[root@stroller root]# vi .bashrc
<ccid_nobr>
<ccid_code># .bashrc# User specific aliases and functionsalias rm='rm -i'alias cp='cp -i'alias mv='mv -i'# Source global definitionsif [ -f /etc/bashrc ]; then. /etc/bashrcfi
然后在 fi 后面加下面语句:
export PATH=/root:$PATH
加完后的 .bashrc 内容为:
<ccid_nobr>
<ccid_code># .bashrc# User specific aliases and functionsalias rm='rm -i'alias cp='cp -i'alias mv='mv -i'# Source global definitionsif [ -f /etc/bashrc ]; then. /etc/bashrcfiexport PATH=/root:$PATH
//在命令行下输入 source .bashrc 执行 .bashrc 生效.
[root@stroller root]# source .bashrc
//查看PATH值:
[root@stroller root]# echo $PATH