lInux 查看和添加环境变量

1. echo $PATH

    xxx@xxx-VirtualBox:/home/openwrt_widora$ echo $PATH

    /home/xxx/bin:

 /home/cheng/.local/bin:

/usr/local/sbin:

/usr/local/bin:

/usr/sbin:

/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

2. export

xxx@xxx-VirtualBox:/home/openwrt_widora$ export
declare -x CLUTTER_IM_MODULE="xim"
declare -x COMPIZ_CONFIG_PROFILE="ubuntu"
declare -x DBUS_SESSION_BUS_ADDRESS="unix:abstract=/tmp/dbus-RvyK9kjBBX"
declare -x DEFAULTS_PATH="/usr/share/gconf/ubuntu.default.path"
declare -x DESKTOP_SESSION="ubuntu"
declare -x DISPLAY=":0"
declare -x GDMSESSION="ubuntu"
declare -x GDM_LANG="en_US"
declare -x GNOME_DESKTOP_SESSION_ID="this-is-deprecated"
declare -x GNOME_KEYRING_CONTROL=""
declare -x GNOME_KEYRING_PID=""
declare -x GPG_AGENT_INFO="/home/cheng/.gnupg/S.gpg-agent:0:1"
declare -x GTK2_MODULES="overlay-scrollbar"
declare -x GTK_IM_MODULE="ibus"
declare -x GTK_MODULES="gail:atk-bridge:unity-gtk-module"
declare -x HOME="/home/cheng"
declare -x IM_CONFIG_PHASE="1"
declare -x INSTANCE="Unity"
declare -x JOB="gnome-session"
declare -x LANG="en_US.UTF-8"
declare -x LANGUAGE="en_US"
declare -x LC_ADDRESS="zh_CN.UTF-8"
declare -x LC_IDENTIFICATION="zh_CN.UTF-8"
declare -x LC_MEASUREMENT="zh_CN.UTF-8"

declare -x LC_MONETARY="zh_CN.UTF-8"

3. 临时添加环境变量  export /opt/buildroot-gcc463/usr/bin

xxx@xxx-VirtualBox:/$ export PATH=/opt/buildroot-gcc463/usr/bin

查看 echo $PATH

xxx@xxx-VirtualBox:/$ echo $PATH

/opt/buildroot-gcc463/usr/bin

4.    永久修改环境变量,影响当前用户

#vim ~/.bashrc
export PATH="/opt/buildroot-gcc463/usr/bin:$PATH"

5.永久添加环境变量(影响所有用户)
vim /etc/profile
在文档最后,添加:
export PATH= "/opt/buildroot-gcc463/usr/bin:$PATH"
保存,退出,然后运行:
# source /etc/profile






你可能感兴趣的:(linux命令)