shell配置,选择,环境变量修改(ORACLE_HOME,ORACLE_SID),无法使用sqlplus
...
零,由于某種誤操作,導(dǎo)致用戶賬戶下的shell配置文件丟失被刪除
一,你登錄到對應(yīng)主機(jī)后,默認(rèn)使用的那種shell
$ echo $SHELL
$ pstree
$ pstree -up|grep sshd
二,bash,csh的全局配置,用戶配置文件
三,配置對應(yīng)的ORACLE_HOME,ORACLE_SID
export?ORACLE_HOME=
export?ORACLE_SID=
=====================================
四,參考資料:
?
http://www.ochef.net/2009/09/compare-unix-shell.html
隨著在Unix和Linux平臺下工作的時(shí)間越長,不同種類的shell繁多,感覺對shell的認(rèn)識由清晰開始變得模糊,所以應(yīng)該趕緊弄清楚它們,shell太重要了。以下內(nèi)容來自互聯(lián)網(wǎng)綜合、整理后的。
.profile:是Bourne Shell (sh)的配置文件,Korn Shell (ksh)兼容sh所以也會使用.profile。
/etc/profile:此文件為系統(tǒng)的每個(gè)用戶設(shè)置環(huán)境信息,當(dāng)用戶第一次登錄時(shí)該文件被執(zhí)行,并從/etc/profile.d目錄的配置文件中搜集shell的設(shè)置。
.bash_ profile:是bash特有的, 由于bash被設(shè)計(jì)成兼容sh、ksh并有csh的特征, 所以會在用戶主目錄依次查找.bash_profile, .bash_login,.profile并用找到的第一個(gè)作為自己的配置文件。
~/.bash_profile:每個(gè)用戶都可使用該文件輸入專用于自己使用的shell信息。當(dāng)用戶登錄時(shí),該文件僅僅執(zhí)行一次。默認(rèn)情況下,它設(shè)置一些環(huán)境變量,執(zhí)行用戶的.bashrc文件。
.login?是C Shell (csh) 的配置文件。
在Linux下sh是bash的一個(gè)鏈接, 如果bash使用sh命令啟動的, 就會以sh兼容方式運(yùn)行使用.profile,可用man bash命令查看更詳細(xì)的解釋。
/etc/bashrc:為每一個(gè)運(yùn)行bash shell的用戶執(zhí)行此文件,當(dāng)bash shell被打開時(shí),該文件被讀取。
~/.bashrc:該文件包含專用于你的bash shell的bash信息,當(dāng)?shù)卿洉r(shí)以及每次打開新的shell時(shí),該該文件被讀取。
~/.bash_logout:當(dāng)每次退出系統(tǒng)(退出bash shell)時(shí),執(zhí)行該文件。另外,/etc/profile中設(shè)定的變量(全局)的可以作用于任何用戶,而~/.bashrc等中設(shè)定的變量(局部)只能繼承/etc/profile中的變量,它們是”父子”關(guān)系。
~/.bash_profile:是交互式、login 方式進(jìn)入 bash 運(yùn)行的;~/.bashrc 是交互式 non-login 方式進(jìn)入 bash 運(yùn)行的。通常二者設(shè)置大致相同,所以通常前者會調(diào)用后者。
-The End-
?
http://space.itpub.net/22666004/viewspace-618337
大家要尊重俺的勞動成果,轉(zhuǎn)載請注明出處。本文首發(fā)自http://blog.csdn.net/erazy0/archive/2009/11/07/4782368.aspx
俺的百度空間http://hi.baidu.com/erazy0以及俺的ITPUB博客http://space.itpub.net/22666004/spacelist-blog也會同步更新
歡迎共同學(xué)習(xí),交流,本人QQ:398467907??? 郵箱:zhaizhibin@hotmail.com
歡迎交換友情鏈接~~
===================================華麗的分割線=========================================
????? 果然,事情永遠(yuǎn)不會一帆風(fēng)順,在連續(xù)出了N次故障后,今天,俺的?Oracle?11g 終于不甘寂寞,再次的出來“興風(fēng)作浪”了。
????? 今天的問題很簡單,我登錄進(jìn)oracle用戶以后,鍵入sqlplus出現(xiàn)如下錯(cuò)誤:
?
--------------------------------------------------------------------------------
[oracle@zzb ~]$ sqlplus
sqlplus:?Command?not?found.
--------------------------------------------------------------------------------
試了幾次又重新啟動都是這樣的,于是立刻去百度,出來一大堆,具體有以下兩種:
oracle環(huán)境變量設(shè)置不正確或者PATH設(shè)置不正確。
root登陸后應(yīng)該 su - oracle,而不是直接 su oracle,中間加短線以繼承oracle用戶的環(huán)境變量。
第2種情況不用考慮,我是用secureCRT直接登錄的oracle,不存在環(huán)境變量沒繼承的問題。
至于第1種情況我記得從沒有改過家目錄下的 .bash_profile 文件,我 vi? .bash_profile 看了一下沒有發(fā)現(xiàn)有什么問題:
--------------------------------------------------------------------------------
[oracle@zzb ~]$ 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
ORACLE_BASE=/u01
ORACLE_HOME=$ORACLE_BASE/oracle
ORACLE_SID=zzb
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
stty erase ^h
#DISPLAY=192.168.0.1:0.0; export DISPLAY
LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
".bash_profile" 28L, 464C written????????????????????????????
[oracle@zzb ~]$ vi .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
ORACLE_BASE=/u01
ORACLE_HOME=$ORACLE_BASE/oracle
ORACLE_SID=zzb
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
stty erase ^h
#DISPLAY=192.168.0.1:0.0; export DISPLAY
--------------------------------------------------------------------------------
于是我又輸入:
--------------------------------------------------------------------------------
[oracle@zzb ~]$ env | grep ORA
[oracle@zzb ~]$
--------------------------------------------------------------------------------
終于出問題了,oracle的環(huán)境變量竟然一個(gè)也沒出來,難道是啟動時(shí)出了什么問題?于是我又輸入:
--------------------------------------------------------------------------------
[oracle@zzb ~]$ source .bash_profile
if:?Expression Syntax.
--------------------------------------------------------------------------------
怪了,竟然出了語法問題。這時(shí)我突然想起來了,這幾天我在學(xué) Shell ,難道是我昨天切換到其他的 shell 下沒有切換回來?似乎只有這樣才會報(bào)語法問題吧,畢竟不同的 shell 之間語法還是有一些差異的。于是我就:
?
--------------------------------------------------------------------------------
[oracle@zzb ~]$ echo $SHELL
/bin/csh
--------------------------------------------------------------------------------
果然是 shell 的問題。于是我:
--------------------------------------------------------------------------------
[oracle@zzb ~]$ exec bash
[oracle@zzb ~]$
[oracle@zzb ~]$ pstree
init─┬─acpid
???? ├─anacron
???? ├─atd
???? ├─crond
???? ├─cups-config-dae
???? ├─cupsd
???? ├─dbus-daemon-1
???? ├─events/0
???? ├─gpm
???? ├─hald
???? ├─htt───htt_server
???? ├─khelper
???? ├─khubd
???? ├─kjournald
???? ├─klogd
???? ├─kseriod
???? ├─ksoftirqd/0
???? ├─kswapd0
???? ├─kthread─┬─aio/0
???? │???????? ├─ata/0
???? │???????? ├─ata_aux
???? │???????? ├─kacpid
???? │???????? ├─kauditd
???? │???????? ├─kblockd/0
???? │???????? └─2*[pdflush]
???? ├─migration/0
???? ├─6*[mingetty]
???? ├─24*[oracle]
???? ├─portmap
???? ├─rpc.idmapd
???? ├─rpc.statd
???? ├─scsi_eh_0
???? ├─2*[sendmail]
???? ├─sshd───sshd───sshd───bash───pstree
???? ├─syslogd
???? ├─udevd
???? ├─vmhgfs
???? ├─vmmemctl
???? ├─vmware-guestd
???? ├─xfs
???? └─xinetd
[oracle@zzb ~]$ env|grep ORA
ORACLE_SID=zzb
ORACLE_BASE=/u01
ORACLE_HOME=/u01/oracle
[oracle@zzb ~]$
?
--------------------------------------------------------------------------------
大家可以看到,現(xiàn)在一切正常了。然后再次輸入:
--------------------------------------------------------------------------------
[oracle@zzb ~]$ source .bash_profile
[oracle@zzb ~]$
?
--------------------------------------------------------------------------------
這次沒報(bào)錯(cuò),然后我就:
?
--------------------------------------------------------------------------------
[oracle@zzb ~]$ sqlplus /nolog
SQL*Plus: Release 11.1.0.6.0 - Production on Sat Nov 7 12:55:15 2009
Copyright (c) 1982, 2007, Oracle.? All rights reserved.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area? 313860096 bytes
Fixed Size????????????????? 1299624 bytes
Variable Size???????????? 226495320 bytes
Database Buffers?????????? 79691776 bytes
Redo Buffers??????????????? 6373376 bytes
Database mounted.
Database opened.
SQL> select * from dual;
D
-
X
--------------------------------------------------------------------------------
可以看到,正常進(jìn)入了。
最后,秉著好奇心,我又輸入:
--------------------------------------------------------------------------------
[oracle@zzb ~]$ echo $SHELL
/bin/csh
--------------------------------------------------------------------------------
額。。。怎么還是 csh,pstree 里顯示的明明只有 bash ,沒辦法,我只能:
--------------------------------------------------------------------------------
[oracle@zzb ~]$ su -
Password:
[root@zzb ~]# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
news:x:9:13:news:/etc/news:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
rpm:x:37:37::/var/lib/rpm:/sbin/nologin
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin
netdump:x:34:34:Network Crash Dump user:/var/crash:/bin/bash
nscd:x:28:28:NSCD Daemon:/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
rpc:x:32:32:Portmapper RPC user:/:/sbin/nologin
mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin
smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
pcap:x:77:77::/var/arpwatch:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin
squid:x:23:23::/var/spool/squid:/sbin/nologin
webalizer:x:67:67:Webalizer:/var/www/usage:/sbin/nologin
xfs:x:43:43:X Font?Server:/etc/X11/fs:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
gdm:x:42:42::/var/gdm:/sbin/nologin
pegasus:x:66:65:tog-pegasus OpenPegasus WBEM/CIM services:/var/lib/Pegasus:/sbin/nologin
htt:x:100:103:IIIMF Htt:/usr/lib/im:/sbin/nologin
named:x:25:25:Named:/var/named:/sbin/nologin
dovecot:x:97:97:dovecot:/usr/libexec/dovecot:/sbin/nologin
erazy0:x:500:500:erazy0:/home/erazy0:/bin/bash
oracle:x:501:501::/u01/oracle:/bin/csh? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<注意這行
[root@zzb ~]# vi /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
news:x:9:13:news:/etc/news:/sbin/nologin
uucp:x:10:14:uucp:/var/spool/uucp:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
games:x:12:100:games:/usr/games:/sbin/nologin
gopher:x:13:30:gopher:/var/gopher:/sbin/nologin
ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
nobody:x:99:99:Nobody:/:/sbin/nologin
dbus:x:81:81:System message bus:/:/sbin/nologin
vcsa:x:69:69:virtual console memory owner:/dev:/sbin/nologin
rpm:x:37:37::/var/lib/rpm:/sbin/nologin
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin
netdump:x:34:34:Network Crash Dump user:/var/crash:/bin/bash
nscd:x:28:28:NSCD Daemon:/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
rpc:x:32:32:Portmapper RPC user:/:/sbin/nologin
mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin
smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin
rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
nfsnobody:x:65534:65534:Anonymous NFS User:/var/lib/nfs:/sbin/nologin
pcap:x:77:77::/var/arpwatch:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin
squid:x:23:23::/var/spool/squid:/sbin/nologin
webalizer:x:67:67:Webalizer:/var/www/usage:/sbin/nologin
xfs:x:43:43:X Font Server:/etc/X11/fs:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
gdm:x:42:42::/var/gdm:/sbin/nologin
pegasus:x:66:65:tog-pegasus OpenPegasus WBEM/CIM services:/var/lib/Pegasus:/sbin/nologin
htt:x:100:103:IIIMF Htt:/usr/lib/im:/sbin/nologin
named:x:25:25:Named:/var/named:/sbin/nologin
dovecot:x:97:97:dovecot:/usr/libexec/dovecot:/sbin/nologin
erazy0:x:500:500:erazy0:/home/erazy0:/bin/bash
oracle:x:501:501::/u01/oracle:/bin/bash
"/etc/passwd" 41L, 1932C written???
--------------------------------------------------------------------------------
注意到被我加紅的那一行,問題就出在這兒,看來是昨天練習(xí) shell 的時(shí)候不小心把oracle用戶的登陸shell給改了,現(xiàn)在我再:
--------------------------------------------------------------------------------
?[oracle@zzb ~]$ echo $SHELL
/bin/bash
?
--------------------------------------------------------------------------------
終于好了,至此,我的 sqlplus 不能登錄的問題應(yīng)該算是圓滿解決了。
PostScripts:貼一段找來的Matlab error "if: Expression Syntax" in tcsh 作為參考
Solution:
The "if: Expression Syntax" error can occur if you have the SHELL environment variable set to something different than what is expected. For example, one MATLAB user reported this error and was able to trace it to their use of "tcsh" instead of "csh." Once they explicitly set the SHELL variable in .matlab6rc.sh to "csh" the "if: Expression Syntax" was resolved.
If you are using "csh" or "tcsh", the "if: Expression Syntax" error may also occur as a result of a syntax error in either the .cshrc or .tcshrc files. Please examine the appropriate file for any errors. Alternatively, you can have MATLAB use "sh" by entering the following before starting MATLAB:
setenv MATLAB_SHELL=/bin/shNote: The method for setting environment variables depends on which shell you are using.
THAT'S ALL.
########################
http://space.itpub.net/519536/viewspace-672034
【故障處理】ORA-12162: TNS:net service name is incorrectly specified
本文將給大家闡述一個(gè)因未設(shè)置系統(tǒng)環(huán)境變量ORACLE_SID導(dǎo)致ORA-12162錯(cuò)誤的案例。希望大家有所思考。
1.獲得有關(guān)ORA-12162報(bào)錯(cuò)信息的通用表述信息
[oracle@asdlabdb01 ~]$ oerr?ora?12162
12162, 00000, "TNS:net service name is incorrectly specified"
// *Cause:? The connect descriptor corresponding to the net service name in
// TNSNAMES.ORA or in the directory server (Oracle Internet Directory) is
// incorrectly specified.
// *Action: If using local naming make sure there are no syntax errors in
// the corresponding connect descriptor in the TNSNAMES.ORA file. If using
// directory naming check the information provided through the administration
// used for directory naming.
2.故障現(xiàn)象
本文所要描述的故障與這個(gè)通用的問題描述不同,在數(shù)據(jù)庫服務(wù)器端使用TNSNAMES.ORA中記錄的連接串連接沒有問題,但如若未指定連接串,將會報(bào)出ORA-12162錯(cuò)誤。
1)使用system用戶嘗試登錄系統(tǒng),此時(shí)便會收到報(bào)錯(cuò)如下信息
[oracle@asdlabdb01 ~]$ sqlplus system/sys
SQL*Plus: Release 10.2.0.3.0 - Production on Sat Aug 27 22:54:02 2010
Copyright (c) 1982, 2006, Oracle.? All Rights Reserved.
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Enter user-name:
2)使用sysdba身份登陸會得到同樣的錯(cuò)誤信息
[oracle@asdlabdb01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Sat Aug 27 22:54:48 2010
Copyright (c) 1982, 2006, Oracle.? All Rights Reserved.
ERROR:
ORA-12162: TNS:net service name is incorrectly specified
Enter user-name:
3)但此時(shí),如果使用服務(wù)名方式連接數(shù)據(jù)庫,是可以成功的,這也是該問題現(xiàn)象的詭異之處。
[oracle@asdlabdb01 ~]$ sqlplus system/sys@ora10g
SQL*Plus: Release 10.2.0.3.0 - Production on Sat Aug 27 22:53:41 2010
Copyright (c) 1982, 2006, Oracle.? All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
system@ora10g>
想象一下,你的目標(biāo)是快速的進(jìn)入到數(shù)據(jù)庫中進(jìn)行維護(hù)操作,但此時(shí)登錄都遭遇障礙,會感到非常的別扭。更讓人抓狂的是,如果此時(shí)使用連接串登錄到數(shù)據(jù)庫進(jìn)行停起操作,結(jié)果將會處于更加慘烈境況:數(shù)據(jù)庫將因?yàn)闊o法正常登錄導(dǎo)致無法啟動數(shù)據(jù)庫。
3.故障原因
詭異的故障背后的原因竟然是那樣的基礎(chǔ):ORACLE_SID沒有指定!
確認(rèn)系統(tǒng)當(dāng)前的ORACLE_HOME和ORACLE_SID環(huán)境變量
[oracle@asdlabdb01 ~]$ echo $ORACLE_HOME
/oracle/app/oracle/product/10.2.0/db_1
[oracle@asdlabdb01 ~]$ echo $ORACLE_SID
[oracle@asdlabdb01 ~]$
可見,此時(shí)只設(shè)置了ORACLE_HOME環(huán)境變量,但ORACLE_SID此時(shí)為空,這就是該問題的真實(shí)原因。
4.故障處理
給出ORACLE_SID,重新嘗試登錄。
[oracle@asdlabdb01 ~]$ export ORACLE_SID=ora10g
[oracle@asdlabdb01 ~]$ echo $ORACLE_SID
ora10g
[oracle@asdlabdb01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.3.0 - Production on Sat Aug 27 23:27:34 2010
Copyright (c) 1982, 2006, Oracle.? All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP and Data Mining Scoring Engine options
sys@ora10g>
OK,此時(shí)問題處理完畢。
5.小結(jié)
這個(gè)案例給我們的啟迪是什么?
1)系統(tǒng)默認(rèn)的錯(cuò)誤提示信息有時(shí)不具有參考價(jià)值。而且,某些情況下這些錯(cuò)誤提示還可能給我們帶來誤導(dǎo)。原因很簡單,系統(tǒng)默認(rèn)的錯(cuò)誤提示信息不可能囊括所有故障現(xiàn)象;
2)任何系統(tǒng)級別的設(shè)置問題都有可能導(dǎo)致數(shù)據(jù)庫系統(tǒng)出現(xiàn)異常;
3)在遇到故障的時(shí)候,我們需要沉著冷靜。有些時(shí)候可能需要我們Check最原始的信息,切莫想當(dāng)然。
建議:為了避免出現(xiàn)文章中提到的問題,第一,可以將ORACLE_SID等環(huán)境變量寫入到系統(tǒng)profile中,但需要確保系統(tǒng)profile文件內(nèi)容的有效性;第二,不在profile中進(jìn)行填寫,每次登錄數(shù)據(jù)庫服務(wù)器時(shí)手工完成數(shù)據(jù)庫環(huán)境變量的指定,這種方法雖然增加了鍵盤的敲擊,但它更直觀、更有保障。
Good luck.
secooler
10.08.27
-- The End --
?
#############################
http://blog.csdn.net/cathysun118/article/details/4197778
?
Sql plus命令報(bào)command not found的解決筆記
1.問題描述
環(huán)境:linux9, Oracle10g.
在一臺裝有Oracle10g的Linux機(jī)器上,我運(yùn)行sqlplus命令,報(bào)錯(cuò)"command not found",
運(yùn)行別的命令(如:lsnrctl)也同樣的錯(cuò)誤。初步懷疑是路徑問題,然后我嘗試cd $oracle_home/bin下,
再次運(yùn)行這些命令,還是同樣的錯(cuò)誤。但用ls能看到這些命令的存在。
2.分析和解決
這種情況應(yīng)該是路徑的問題,應(yīng)該Oracle剛剛安裝成功的,而且安裝過程中沒有出現(xiàn)異常。
我echo $oracle_home為空,echo $path也為空,問題就出在這里了。
然后我
export ORACLE_HOME=<your Oracle Home>
export PATH=$ORACLE_HOME/bin:$PATH
再次運(yùn)行Sqlplus命令,ok,可以了。
最后,我用vi編輯 .profile文件,把
export ORACLE_HOME=<your Oracle Home>
export PATH=$ORACLE_HOME/bin:$PATH
加入.profile中。保存。
用source .profile啟用該資源文件。
重新進(jìn)入Linux系統(tǒng),sqlplus命令一切正常。
?
?
?
#############################################
http://wiki.freebsdchina.org/howto/c/config_your_csh
?
選擇?csh/tcsh
和許多剛從 Linux 轉(zhuǎn)到 BSD 的人不同,我并沒有裝完 BSD 就順手安裝?bash,
因?yàn)橹俺舜蛎?#xff0c;我沒有用到額外的功能,bash?也好,csh?也罷,在我眼里都是當(dāng)做 shell 來用。
但是漸漸地,我發(fā)現(xiàn)?csh?真的挺好用,它小巧、簡單、開放,不需要額外依賴。
可能有人要拿腳本能力來作對比,比如bash腳本支持函數(shù),csh不支持等。
對我來說,其實(shí)我從未像模像樣地寫過一個(gè)腳本,我的工作是 C++ 程序員。
從我的角度來看,
論腳本能力,其實(shí)bash、csh、zsh都比不上Python,
論兼容性,bash、csh、zsh都比不上sh,
論強(qiáng)大,bash、csh、zsh都比不上C/C++,甚至asm。
再看易學(xué)程度,bash、csh、zsh可能還是要輸給Python。
綜上,腳本能力忽略不計(jì)。
好了,說了這么多大不敬的話,我們開始切入正題。
配置文件
全局配置文件 /etc/csh.cshrc
個(gè)人配置文件 ~/.cshrc或~/.tcshrc
為了方便,建議修改全局性的配置文件,這樣每個(gè)賬號都可以享受便利。
按鍵綁定
通常,我們不設(shè)置按鍵綁定也能很好地工作,
但是對于遠(yuǎn)程登錄,可能需要一些額外的配置。
比如,為了避免putty登錄后,Home、End、Delete等變成~,你需要如下配置:
提示符
設(shè)置一個(gè)漂亮使用的的提示符可以讓工作變得更愉快高效。
以下是一個(gè)合理的配置方案:
Konsole中的效果如下:
一種彩色的配置方案如下:
set cr = "%{\e[31m%}" #開始紅色 set cg = "%{\e[32m%}" #開始綠色 set c0 = "%{\e[0m%}" #恢復(fù)為默認(rèn)色彩# Set some variables for interactive shells if ( $?prompt ) thenif ( "$uid" == "0" ) thenset prompt = "%B%U%n%u@%m.$cr%l$c0%b %c2 %B%#%b " elseset prompt = "%B%U%n%u@%m.$cg%l$c0%b %c2 %B%%%b "endif endifKonsole中的效果如下:
顏色代碼:
1 for brighter colors
4 for underlined text
5 for flashing text
30 for black foreground
31 for red foreground
32 for green foreground
33 for yellow (or brown) foreground
34 for blue foreground
35 for purple foreground
36 for cyan foreground
37 for white (or gray) foreground
40 for black background
41 for red background
42 for green background
43 for yellow (or brown) background
44 for blue background
45 for purple background
46 for cyan background
47 for white (or gray) background
查看更多參數(shù),及其作用:
man tcsh #查看man手冊 /%/ #搜索到“%/”開始的地方環(huán)境變量等
你在抱怨 FreeBSD下的 ls 沒有顯示顏色, grep 出來的東西沒有高亮嗎? 那么你需要如下的配置:
#讓 ls 鮮艷些 setenv LSCOLORS ExGxFxdxCxegedabagExEx setenv CLICOLOR yes #讓 grep 匹配到的字符高亮 setenv GREP_OPTIONS --color=auto對于在KDE下使用fcitx的人,需要如下三行設(shè)置,
其實(shí)就是fcitx安裝完后所提示的內(nèi)容,如果你夠細(xì)心的話。
嗯, ls 有顏色了,但是等等,為何 tab 不能補(bǔ)全?
你需要如下配置:
如果命令輸錯(cuò)了,讓csh/tcsh 為你糾正:
set correct = cmd為了在命令行啟動某個(gè)游戲,或者kde程序,例如dolphin、kcalc,
你需要加兩個(gè)路徑到$path中去:
/usr/games /usr/local/kde4/bin/
黑魔法防御術(shù)
重定向防御
重定向很強(qiáng)大,我們有時(shí)候會運(yùn)行諸如“date ? b.txt”,“l(fā)s -l > files.txt”等命令。
然而如果一不小心,把“?”輸成“>”會造成什么后果呢?
為此,tcsh提供了noclobber這個(gè)選項(xiàng):
有了它,悲劇就不會發(fā)生。如果“>”的目標(biāo)文件已存在,tcsh會拒絕重定向。
覆蓋防御
是否遇到過“mv a b”,從而把有用的b文件覆蓋掉了?
為此,我們要讓mv和cp的行為更謹(jǐn)慎:
如果目標(biāo)文件已存在,mv和cp會拒絕操作,除非使用參數(shù)“-f”。
誤刪防御
rm這個(gè)命令自從誕生起,就一直是個(gè)危險(xiǎn)的操作。
我們可以讓rm更溫和:
這樣rm之前,會要求再次確認(rèn)。
一切皆alias
前面,我們在黑魔法防御術(shù)中已經(jīng)初步見識了alias。
alias不僅可以避免危險(xiǎn)操作,還可以簡化命令,自創(chuàng)命令。
除非極短,否則良好的alias命名,應(yīng)當(dāng)以某個(gè)統(tǒng)一的單詞或字母開頭,
例如下面即將展示的reload/edit系列、update系列、show系列等。
先展示最基本的alias,并逐條解釋。
alias .. 'cd ..' #兩點(diǎn)即可回到上級目錄 alias - 'cd -' #一杠返回上次的目錄 alias q 'exit' #退出登錄 alias rm 'rm -i' #誤刪防御 alias del 'rm -r' #刪除整個(gè)目錄 alias mv 'mv -i' #覆蓋防御 alias cp 'cp -i' #覆蓋防御 alias ls 'ls -I' #root狀態(tài)下,默認(rèn)不顯示隱藏文件(.*)。BSD的ls很特殊,root默認(rèn)顯示所有文件。 alias la 'ls -a' #顯示所有文件 alias ll 'ls -h -l' #顯示文件權(quán)限和大小(以合理的單位) alias lr 'ls -R' #遞歸顯示目錄 alias dh 'df -h -a -T' #以合適的單位顯示所有磁盤的剩余空間,以及文件系統(tǒng)類型(如ufs、devfs、procfs)。 alias ds 'du -sh' #以合適的單位顯示查看每個(gè)文件/文件夾的大小find/wc系列。快速查找當(dāng)前目錄下的所有c/cxx/python源碼文件。結(jié)合wc可以統(tǒng)計(jì)行數(shù)。
alias find-c 'find . -name "*.h" -o -name "*.c"' alias find-x 'find . -name "*.h" -o -name "*.hpp" -o -name "*.cpp" -o -name "*.cxx"' alias find-py 'find . -name ".py"' alias wc-c 'find . -name "*.h" -o -name "*.c" | xargs wc | sort -k 4' alias wc-x 'find . -name "*.h" -o -name "*.hpp" -o -name "*.cpp" -o -name "*.cxx" | xargs wc | sort -k 4' alias wc-py 'find . -name ".py" | xargs wc | sort -k 4'reload/edit系列。實(shí)現(xiàn)快速修改,載入配置文件。
alias reload-rc.conf 'sh /etc/rc' alias reload-cshrc 'unalias * && source /etc/csh.cshrc' alias edit-xorg.conf 'vim /etc/xorg.conf' alias edit-csh.cshrc 'vim /etc/csh.cshrc' alias edit-make.conf 'vim /etc/make.conf' alias edit-kern.conf 'vim /etc/kernconf/thinkpad' alias edit-rc.conf 'vim /etc/rc.conf' alias edit-vimrc 'vim /usr/local/share/vim/vimrc'set系列。快速設(shè)置locale。
alias setlocale-zhcn 'setenv LC_ALL zh_CN.UTF-8 && setenv LANG zh_CN.UTF-8' alias setlocale-c 'setenv LC_ALL C'startx專用。
保持命令行下為英文locale(避免date等命令出現(xiàn)亂碼),而讓x環(huán)境為中文,適合手動startx而不是kdm的人。
make系列??焖倬幾gkernel/world。
alias make-world 'cd /usr/src && make buildworld && cd -' alias make-kernel 'cd /usr/src && make kernel KERNCONF=thinkpad && cd -' alias make-installworld 'cd /usr/src && make installworld && make delete-old && cd -'show系列。查看狀態(tài)或某些信息。
alias show-ifstat 'systat -ifstat' #查看網(wǎng)絡(luò)接口的數(shù)據(jù)流量 alias show-geom 'gstat' #查看I/O狀態(tài) alias show-thermal 'sysctl dev.acpi_ibm.0.thermal' #查看ThinkPad筆記本的各部分溫度 alias show-cpufreq 'sysctl dev.cpu.0.freq' #查看當(dāng)前cpu頻率 alias show-cpulevels 'sysctl dev.cpu.0.freq_levels' #查看可用的cpu頻率 alias show-battery 'sysctl hw.acpi.battery.life && sysctl hw.acpi.battery.time' #查看電力 alias show-smartctl 'smartctl -a /dev/ad4' #需要安裝smartmontools,查看磁盤smart參數(shù) alias show-alldep 'make all-depends-list' #需要在ports的安裝目錄下執(zhí)行,顯示所有依賴 alias show-dep 'portmaster --show-work ./ | sort' #同上,且需要安裝portmaster,只顯示尚未安裝的依賴 alias show-ver 'pkg_version -v' #查看是否有軟件可更新update系列。顧名思義,更新嘛。
alias update-locatedb '/usr/libexec/locate.updatedb' #更新locate數(shù)據(jù)庫 alias update-kernsrc 'csup -L 2 /etc/supfiles/stable-supfile' #同步kernel tree alias update-ports 'portsnap fetch update' #同步ports tree alias update-apps 'portmaster -a --force-config' #需要安裝portmaster,更新所有軟件,提示配置選項(xiàng)雜項(xiàng),均需要安裝第三方軟件才能用。
alias lt 'tree -N -C' #需要安裝tree。樹狀顯示目錄,-N可以保證中文顯示,-C使用彩色 alias l3 'tree -N -C -L 3' #目錄最多遞歸三級 alias l4 'tree -N -C -L 4' #四級 alias l5 'tree -N -C -L 5' #五級 alias l6 'tree -N -C -L 6' #六級 alias v 'vim' #不用說,我懶 alias m 'mocp' #控制臺下的cs架構(gòu)播放器 alias getdir 'wget -c -r -np -k' #遞歸下載目錄 alias ssh-home 'ssh raphael.vicp.cc -l root' #用root賬號登錄,結(jié)合key可以免輸密碼 alias ftp-home 'ftp ftp://syh:syh@raphael.vicp.cc' #BSD自帶的ftp,免輸賬號密碼。主機(jī)已被電信和工信部和諧,勿再試 alias lft-phome 'lftp raphael.vicp.cc -u syh,syh' #lftp的免輸賬號密碼。 alias scons 'scons -Q -j 4' #構(gòu)建工具,默認(rèn)4個(gè)線程進(jìn)行 alias valgrind-checkmem 'valgrind --tool=memcheck --leak-check=full' #檢查內(nèi)存泄漏最好的教材
最好的教材莫過于man手冊,真的什么都有了。
man tcsh##################
http://www.oschina.net/question/12_6576
一、選擇一個(gè)好SHELL?
Unix?中常見的?shell?主要分為兩大門派:?
sh:?
burne?again?shell?(bash)
????????csh:?
c?shell?(csh)
tc?shell?(tcsh)
korn?shell?(ksh)
本人的教學(xué)環(huán)境是?FreeBSD6.1?+?sh?,你也可以使用bash來學(xué)習(xí),bash兼容sh。我盡量將所有的SHELL語句也在Redhat上面驗(yàn)證一下。?
FreeBSD上bash的安裝方法有二:?
1、pkg_add?-r?bash
2、cd?/usr/ports/shell/bash2?&&?make?install?clean
Linux?上默認(rèn)的SHELL已經(jīng)是bash了。?
查看自己機(jī)器上支持?Shell?種類的方法:?
#?cat?/etc/shells?
/bin/sh
/bin/csh
/bin/tcsh
/usr/local/bin/bash
設(shè)置自己的SHELL為sh?
#?chsh
#?vipw
使用chsh命令會打開一個(gè)編輯器(類似vi),需要修改其中的Shell:?/bin/csh一項(xiàng)為Shell:?/bin/sh?
使用vipw命令會打開一個(gè)編輯器(類似vi),需要修改指定用戶所在行的最后一項(xiàng)為/bin/sh?
如果你是在FreeBSD上安裝了?bash?,一般修改為?/usr/local/bin/bash?
二、SHELL基礎(chǔ)(UNIX中的常用命令)?
[color=Red]列出目錄中的內(nèi)容[/color]?
ls?
[color=Red]FreeBSD需要使用使用-G參數(shù),才能按文件類型顯示為約定的顏色[/color]?
ls?-G?
[color=Red]使用長格式,更出目錄中的內(nèi)容[/color]?
ls?-l?
[color=Red]顯示一個(gè)文本文件的內(nèi)容[/color]?
cat? <文件名>?
cat?-n?/etc/passwd??(顯示文件,并加行號)?
less? <文件名>?
more? <文件名>?
[color=Red]復(fù)制文件[/color]cp? <源文件名> ? <目標(biāo)文件名>?
[color=Red]文件更名或移動文件至其他目錄[/color]?
mv? <文件名1> ? <文件名2>?
mv? <目錄1> <文件名> ? <目錄2> <文件名>?
[color=Red]顯示當(dāng)前工作的目錄[/color]?
pwd??
[color=Red]建立目錄(-p?建立多級目錄)[/color]?
mkdir? <目錄名>?
mkdir?-p? <目錄1> / <目錄2>?
[color=Red]刪除文件(或目錄)[/color]?
rm? <文件名>?
rm?-rf? <目錄>?
[color=Red]顯示時(shí)間和日期[/color]?
date?
[color=Red]顯示N天前的時(shí)間和日期[/color]?
date?-v?-2d?
[color=Red]其他格式請自己試一下,或查看手冊??man?date[/color]?
date?+%F?
date?"+DATE:?%Y-%m-%d%nTIME:?%H:%M:%S"?
[color=Red]顯示字符串[/color]?
echo?"hello?c?shell"?
printf?"hello?c?shell\n"?
[color=Red]顯示帶顏色的字符串[/color]?
echo?-e?"\e[31mRed?String\e[0m"?
printf??"\e[31mRed?String\e[0m\n"?
具體的顏色代碼,請參考:?http://www.51sincere.com/2006-11/20061123123521.htm
?
總結(jié)
以上是生活随笔為你收集整理的shell配置,选择,环境变量修改(ORACLE_HOME,ORACLE_SID),无法使用sqlplus的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: column 格式化列显示 命令介绍
- 下一篇: 面试题:利用一个栈倒序另外一个栈中的数