Linux中PATH设置

Linux中PATH设置

时间:2009-10-25来源:Online990 作者: Online990点击:1051次

PATH的值是一系列目录,当您运行一个程序时,Linux在这些目录下进行搜寻,用以下命令可以设置PATH的值。

 

直接用export命令

在PATH中加入/data/test/hellow.sh脚本,使该脚本能在其他目录下执行。

[root@localhost /]# cd /data/test

[root@localhost test]# ll

总用量 4

-rwx——  1 root root 32 10月 25 13:02 hellow.sh

[root@localhost test]# echo $PATH       #显示$PATH变量

/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin

[root@localhost test]# cd /

[root@localhost /]# export PATH=/data/test:$PATH      #在$PATH中加入脚本路径

[root@localhost /]# export|grep test      #查看$PATH

declare -x OLDPWD=”/data/test”

declare -x PATH=”/data/test:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin”

 

修改profile文件

[root@localhost /]# vi /etc/profile

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC    #加入

 

修改.bash文件

[root@localhost /]# vi/root/.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=”$PATH:/data/test/”

通过Linux中PATH设置 – online990.

Advertisements
This entry was posted in linux and tagged .

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s