1. 可用 export 命令查看PATH值
[root@localhost u-boot-sh4]# export
2. 单独查看PATH环境变量,可用:
[root@localhost u-boot-sh4]#echo $PATH
3. 添加PATH环境变量(临时),在终端关闭 后就会消失,可用:
[root@localhost u-boot-sh4]#export PATH=/opt/STM/STLinux-2.3/devkit/sh4/bin:$PATH
4. 永久添加环境变量(影响当前用户)
#vim ~/.bashrc
export PATH=”/opt/STM/STLinux-2.3/devkit/sh4/bin:$PATH”
5.永久添加环境变量(影响所有用户)
# vim /etc/profile
在文档最后,添加:
export PATH=”/opt/STM/STLinux-2.3/devkit/sh4/bin:$PATH”
保存,退出,然后运行:
#source /etc/profile
不报错则成功。
注意,如果在用户不登录的情况下,执行脚本文件,可能会找不到系统环境变量,因为没有执行 /etc/profile,所以需要在脚本中加入source /etc/profile,方能生效系统环境变量,或者在脚本中,使用export xx,方能使用环境变量。