天天看點

linux查詢環境變量檔案,linux中檢視環境變量的兩種方法

linux中檢視環境變量有兩種方法:

第一種是看系統環境變量的配置檔案:

/etc/profile這個是環境變量配置檔案,裡面是應經配置号的環境變量。當你在Ubuntu上安裝配置jdk的JAVA_HOME時,需要把路徑配置在裡面。

例如:

在bash下輸入gedit /etc/profile

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))

# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "$PS1" ]; then

if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then

# The file bash.bashrc already sets the default PS1.

# PS1='\h:\w\$ '

if [ -f /etc/bash.bashrc ]; then

. /etc/bash.bashrc

fi

else

if [ "`id -u`" -eq 0 ]; then

PS1='# '

else

PS1='$ '

fi

fi

fi

# The default umask is now handled by pam_umask.

# See pam_umask(8) and /etc/login.defs.

if [ -d /etc/profile.d ]; then

for i in /etc/profile.d/*.sh; do

if [ -r $i ]; then

. $i

fi

done

unset i

fi

#set Java Environment

export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_67

export CLASSPATH=".:$JAVA_HOME/lib:$CLASSPATH"

export PATH="$JAVA_HOME/:$PATH"

如果沒有找到環境變量,那就是環境變量沒有配好。

第二種方法使用指令:

還可以用env指令,這個是檢視目前系統的環境變量的。

要分頁的話就加通道 env |more。