当前位置:文档之家› Solaris常用命令和例子

Solaris常用命令和例子

Solaris常用命令和例子1)ok>probe-ide//Ultra5/10、Blade100/150ok>probe-scsi-all//Ultra60、E450、V480ok probe-scsi-all/pci@1f,4000/scsi@3,1/pci@1f,4000/scsi@3Target 0Unit 0 Disk QUANTUM VK4550J SUN4.2G8817Target 6Unit 0 Removable Read Only device TOSHIBA 2395 XM5701TASUN12XCDfsck例:ok bootBoot path: /ssm@0,0/pci@1c,700000/pci@1/SUNW,isptwo@4/sd@0,0:a Boot args: -s Loading ufs-file-system package 1.4 04 Aug 1995 13:02:54.FCode UFS Reader 1.11 97/07/10 16:19:15.Loading: /platform/SUNW,Sun-Fire/ufsbootLoading: /platform/sun4u/ufsbootSunOS Release 5.8 Version Generic_110096-04 64-bitCopyright 1983-2000 Sun Microsystems, Inc. All rights reserved.WARNING: todsg_get(): TOD SRAM magic errorWARNING: todsg_get(): turned off using todconfiguring IPv4 interfaces: hme1.Hostname: qame-aThe / file system (/dev/rdsk/c4t0d0s0) is being checked./dev/rdsk/c4t0d0s0: INCORRECT BLOCK COUNT I=50905 (4 should be 0) (CORRECTED) /dev/rdsk/c4t0d0s0: INCORRECT BLOCK COUNT I=50906 (2 should be 0) (CORRECTED) /dev/rdsk/c4t0d0s0: INCORRECT BLOCK COUNT I=50907 (2 should be 0) (CORRECTED) /dev/rdsk/c4t0d0s0: INCORRECT BLOCK COUNT I=539350 (18 should be 0) (CORRECTED) /dev/rdsk/c4t0d0s0: INCORRECT BLOCK COUNT I=539351 (2 should be 0) (CORRECTED) /dev/rdsk/c4t0d0s0: INCORRECT BLOCK COUNT I=753040 (2 should be 0) (CORRECTED) /dev/rdsk/c4t0d0s0: INCORRECT BLOCK COUNT I=804088 (2 should be 0) (CORRECTED) /dev/rdsk/c4t0d0s0: INCORRECT BLOCK COUNT I=881943 (2 should be 0) (CORRECTED) /dev/rdsk/c4t0d0s0: INCORRECT BLOCK COUNT I=881944 (2 should be 0) (CORRECTED) /dev/rdsk/c4t0d0s0: INCORRECT BLOCK COUNT I=885317 (6 should be 0) (CORRECTED) /dev/rdsk/c4t0d0s0: 7499747 DUP I=885355/dev/rdsk/c4t0d0s0: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY. WARNING - Unable to repair the / filesystem. Run fsckmanually (fsck -F ufs /dev/rdsk/c4t0d0s0). Exit the shell whendone to continue the boot process.Type control-d to proceed with normal startup,(or give root password for system maintenance):#fsck –yok boot cdrom –s#fsck –y /dev/rdsk/c0t0d0s02)终端控制ctrl+s :终止屏幕输出,如用cat命令输出时,要停一下ctrl+q :恢复ctrl+q的输出ctrl+c :中断当前的活动,返回命令提示符ctrl+d :表示文件的结束或退出,如退出终端窗口ctrl+u :擦除整个命令行ctrl+w :擦除命令行最后一个单词ctrl+h :擦除命令行最后一个字符3)# uname–a //查看操作系统版本以及内核版本SunOS <hostname> 5.7 Generic_106541-19 sun4u sparc sun4uSunOS:OS5.5.1=solaris2.5.1OS5.6=solaris2.6OS5.7=solaris7OS5.8=solaris8Unix kernel:32 bit SPARC - /platform/sun4u/kernel/unix64 bit SPARC - /platform/sun4u/kernel/sparcv9/unixintel - /platform/i86pc/kernel/unix4)# date# date mmddHHMM[[cc]yy][.SS]# date2003年10月12日星期日 10时04分16秒 CST(CST是Chinese Standard Time的缩写)# date 10121003 设置时间为10月12日10时03分5)#stings#stings /usr/bin/cat能够用来打印可执行文件或二进制文件中的可读字符。

6)常用文本文件的命令#cat -n test.txt //显示行号#more test.txt | more键值目的空格滚动到下一屏回车一次滚动一行b 向后移动一屏f 向前移动一屏h 显示更多特性的帮助菜单q 退出,返回shell提示符/string 向前搜索字符串stringn 查找下一处匹配head#head -5 /export/home/wing/test.txt //显示开始的5行#head chap*|more //显示所有以chap开头的文件的头部用来显示一个或多个文件的前n行,默认省略-n参数将显示文件的前10行。

tail#tail -5 /export/home/wing/test.txt //显示最后5行#tail +5 /export/home/wing/test.txt //显示第5行开始到结束用来显示一个文件的最后n行,默认省略-n参数将显示文件的最后10行。

# tail -f /var/adm/messages //实时自动浏览syslog入口Oct 6 00:20:26 wing genunix: [ID 936769 ] sd0 is /pci@0,0/pci-ide@7,1/ide@1/sd@0,0 Oct 6 00:20:26 wing pcplusmp: [ID 637496 ] pcplusmp: fdc (fdc) instance 0 vector 0x6 i oapic 0x1 intin 0x6 is bound to cpu 0Oct 6 00:20:26 wing last message repeated 1 timeOct 6 00:20:26 wing isa: [ID 202937 ] ISA-device: fdc0Oct 6 00:20:26 wing fdc: [ID 114370 ] fd0 at fdc0Oct 6 00:20:26 wing genunix: [ID 936769 ] fd0 is /isa/fdc@1,3f0/fd@0,0Oct 6 00:20:30 wing i8042: [ID 526150 ] 8042 device: mouse@1, mouse8042 # 0Oct 6 00:20:30 wing genunix: [ID 936769 ] mouse80420 is /isa/i8042@1,60/mouse@1 Oct 6 00:21:37 wing login: [ID 722452 auth.error] user2netname: (nis+ lookup): Error in accessinIS+ cold start file... is NIS+ installed?Oct 6 00:21:47 wing last message repeated 1 timeOct 6 00:52:07 wing login: [ID 722452 auth.error] user2netname: (nis+ lookup): Error in accessin g NIS+ cold start file... is NIS+ installed?wc#wc /export/home/wing/test.txt //显示文件的行、单词、字节数#wc -l /export/home/wing/test.txt //显示文件的行数选项功能-l 统计行数-w 统计单词数-c 统计字节数-m 统计字符数diff#diff -i test.txt test2.txt //忽略文章中的大小写#diff -c test.txt test2.txt //进行细致的比较生成一个差别表8)常用文件和文件夹操作命令:touch#touch test1.txt test2.txt test3.txt //可以一次创建多个文件mkdir#mkdir /export/home/wing#mkdir -p /export/home/wing //在路径中名中不存在的目录将被创建#rmdir dir //所要删除的目录必须是空的rmrm -i test.txt test2.txt //交互式删除文件rm -r /tem/testd //删除目录和目录下的文件rm -ir /tem/testd //交互式的删除目录和目录下的文件cpcp -i oldfilename newfilename //交互式拷贝cp /export/home/keven/ok.txt /export/home/wing/test.txtcp -ri /export/home/keven /export/home/wing 整个目录一起拷cp -rp 文件属性一起拷贝$ ls -n总数 12-rw-r--r-- 1 0 1 247 10月 2 07:53 list-rw-r--r-- 2 1002 100 62 10月 2 01:10 ok.txtdrwxr-xr-x 2 0 1 512 10月 1 21:27 ss-rw-r--r-- 1 1002 100 171 10月 3 01:10 test.txt-rw-r--r-- 1 1002 100 120 10月 2 20:54 test1-rw-r--r-- 1 1002 100 0 9月 30 08:54 test2-rw-r--r-- 1 1002 100 0 9月 30 08:54 test3-rw-r--r-- 1 0 1 247 10月 2 07:58 tt.txt# ls -ld using_samba //查看目录的权限drwxr-xr-x 2 root other 512 5月 8 22:23 using_samba$ ls -a. .cshrc list ss test1 test3.. .login ok.txt test.txt test2 tt.txt$ ls -l总数 12-rw-r--r-- 1 root other 247 10月 2 07:53 list-rw-r--r-- 2 keven user 62 10月 2 01:10 ok.txtdrwxr-xr-x 2 root other 512 10月 1 21:27 ss-rw-r--r-- 1 keven user 171 10月 3 01:10 test.txt-rw-r--r-- 1 keven user 120 10月 2 20:54 test1-rw-r--r-- 1 keven user 0 9月 30 08:54 test2-rw-r--r-- 1 keven user 0 9月 30 08:54 test3-rw-r--r-- 1 root other 247 10月 2 07:58 tt.txt$ ls -F //列出目录名TT_DB/ keven/ temp/ user2/ www/cole/ lost+found/ user1/ wing/符号文件类型/ 文件夹* 可执行文件(none)无格式文件或者ASCII文件@ 链接符如:# ls -Faccept* gsscred* metaset* i86/ //目录acctadm* halt* metastat* roleadd*add_drv* hostconfig* metasync* test.txt //ASCIIcachefslog@ in.rlogind* mount* rtquery*cachefswssize@链接文件 in.routed* mountall* rwall*//可执行文件$ ls -R //递归显示.:TT_DB keven temp user2 wwwcole lost+found user1 wing./cole:inetservices.txt services services.txt./keven:dir test.txt./keven/dir:./lost+found:./lost+found: 权限被否定./temp:so.tar.gz./user1:./user2:./wing:aa dead.letter mywife.tar ok passwd.txt test./wing/test:./www:$$ ls . //显示当前目录dir test.txt$ ls .. //显示当前目录的父目录,支持路径表示符如~TT_DB keven temp user2 wwwcole lost+found user1 wing$ ls -i test.txt test1.txt //节点检查64 test.txt 65 test1.txt$ ls -il test.txt test1.txt64 -rw-r--r-- 1 keven sysadmin 27 10月 12 17:27 test.txt65 -rw-r--r-- 1 keven sysadmin 0 10月 12 17:25 test1.txt$ ls -ld //只显示目录drwxr-xr-x 3 keven sysadmin 512 10月 12 17:25 .file$ file passwd.txtpasswd.txt: ascii文本lp$lp ok.txt myfile test.txt$lp -p evans1 test.txt //-p后为打印机evans1$lpstat // 打印队列状态ln#ln file1 newfile#ln file1 directory/newfilename 硬链接#ln ~/book/chap* /home/brad为每个chap文件都创建了链接,把这些链接指向/home/brad目录如果文件有多个指向它的硬盘链接,只是删除该文件并不能有效的释放磁盘空间,你将不得不删除掉所有指向它的硬链接。

相关主题