红联Linux门户
Linux帮助

linux下PATH设置

发布时间:2008-02-18 12:47:12来源:红联作者:userhq
假设你要执行的程序路径在 /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
文章评论

共有 3 条评论

  1. prinse 于 2009-10-27 12:16:17发表:

    引用:
    WBD,千万不要照上面做,会导致PATH全被清掉。猪!!!
    frog76 发表于 2009-10-17 11:22


    可能吗?

  2. frog76 于 2009-10-17 11:22:05发表:

    WBD,千万不要照上面做,会导致PATH全被清掉。猪!!!

  3. dzj 于 2008-02-24 00:05:39发表:

    mark