linux下查看和添加path环境变量

单独查看PATH环境变量,可用: 

 

[root@localhost u-boot-sh4 #]echo $PATH 

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

 

添加PATH环境变量: 

第一种方法:

[root@localhost u-boot-sh4 #]export PATH=/opt/STM/STLinux-2.3/devkit/sh4/bin:$PATH 

 

再次查看: 

 

[root@localhost u-boot-sh4 #] echo $PATH 

/opt/STM/STLinux-2.3/devkit/sh4/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

 

说明添加PATH成功。 

 

上述方法的PATH 在终端关闭 后就会消失。所以还是建议通过编辑~/.bashrc或~/.bash_profile或系统级别的/etc/profil来改PATH,也可以改家目录下的.bashrc(即:~/.bashrc)。 

 

第二种方法: 

# vim /etc/profile 

在文档最后,添加: 

export PATH="/opt/STM/STLinux-2.3/devkit/sh4/bin:$PATH" 

保存,退出,然后运行: 

#source /etc/profile 

不报错则成功。 

 

posted @ 2016-06-24 10:32  龙昊雪  阅读(8545)  评论(0编辑  收藏  举报