方法一:
該方法只能修改臨時配置文件,當每次系統重啟后,配置文件將失效
假如我的安裝路徑如下:/home/oracle/app/oracle/product/11.2.0/dbhome_1/bin
那么在 /home/lxm/.bash_profile
文件中添加如下內容:
export ORACLE_BASE=/home/lxm/app/lxm
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
然后執行:source /home/lxm/.bash_profile
使其生效即可
輸入sqlplus /nolog
出現如下提示:
[lxm@wn7-lcg /]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Mon Oct 15 14:10:56 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
SQL>
就成功了
方法二:如何修改系統配置文件
1、只對當前登錄用戶有作用
vi ~/.bash_profile
export JAVA_HOME=/home/java/jdk1.8
export JAVA_BIN=$JAVA_HOME/bin
export PATH=$JAVA_BIN:$PATH
2、對所有用戶有效
vi /etc/profile
export JAVA_HOME=/home/java/jdk1.8
export JAVA_BIN=$JAVA_HOME/bin
export PATH=$JAVA_BIN:$PATH
使環境變量生效 source /etc/profile
注意:最后還需要在/etc/bashrc配置文件中添加參數配置,如果這不添加參數,將不會永久生效