下面是oracle环境变量的设置。
[root@rhel4 ~]# su - oracle
[oracle@rhel4 ~]$ pwd/home/oracle
[oracle@rhel4 ~]$ vi .bash_profile
------------------------------------------------------------------------------------------------
# .bash_profile# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
unset USERNAME
#add 2013-5-1 for oracle
export EDITOR=vi
export ORACLE_SID=orcl
export ORACLE_BASE=/u01/app/oracle/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export PATH=/u01/app/oracle/oracle/product/10.2.0/db_1/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin
export PATH=$ORACLE_HOME/bin:$PATH
umask 022 ----新建文件夹是777-022=755(rwxr-xr-x),新建文件是666-022=644(rw-r--r--)。
#add 2013-5-2
stty erase ^H ---退格
stty erase ^?
---------------------------------------------------------------------------------------
[oracle@rhel4 ~]$ source ~/.bash_profile ---使设置生效
[oracle@rhel4 ~]$ echo $ORACLE_HOME
/u01/app/oracle/oracle/product/10.2.0/db_1
[oracle@rhel4 ~]$ echo $ORACLE_SID
orcl
[oracle@rhel4 ~]$ echo $ORACLE_BASE
/u01/app/oracle/oracle
然后执行在$oracle_home/bin下执行sqlplus
[oracle@rhel4 ~]$ cd $ORACLE_HOME/bin
[oracle@rhel4 bin]$ pwd
/u01/app/oracle/oracle/product/10.2.0/db_1/bin
[oracle@rhel4 bin]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Thu May 2 22:40:14 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
但是如果不在$oracle_home/bin下执行sqlplus,可能仍然会出现 bash: sqlplus: command not found,
那么在root用户下执行 ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
ln 相当于建立快捷方式
在sqlplus中不能使用上下左右方向键,参见
点击打开链接
另外,留意.bash_profile 与.bashrc的区别