`
cynan168
  • 浏览: 37671 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Solaris 中文命令

阅读更多
Solaris/Linux 命令手册

1. 系统
# passwd:修改口令
# exit:退出系统

2. 文件
# cp:复制文件或目录,参数:-a递归目录,-i覆盖确认
# mv:改名移动
# rm:删除,参数:-r递归删除

3. 目录
# mkdir:创建目录
# rmdir:删除空目录
# cd:改变工作目录
# pwd:查看当前路径
# ls:列目录,参数:-a所有文件,-c按时间排序,-l详细信息

4. 文本
# sort:排序
# uniq:删除重复行

5. 备份压缩
# tar:档案,参数:-c创建新档案,-r追加到末尾,-t列出档案内容,-u更新文件,-x释放文件,-f使用档案文件或设备,-M多卷,-v详细报告,-w每步确认。例tar cvf text.tar *.txt
# gzip:压缩解压缩,参数:-d解压,-r递归压缩
# unzip:解压缩,参数:-d目录,-x解压缩

6. 权限
# chmod:改变权限,r可读,w可写,x可执行。0表示没有权限,1表示可执行权限,2表示可写权限,4表示可读权限,然后将其相加。例如,如果想让某个文件的属主有“读/写”二种权限,需要把4(可读)+2(可写)=6(读/写)。
# chgrp:改变所属用户组
# chown:改变属主

7. 管理
# wall:发送信息到全部登录用户
# write:向某个用户发送信息
# mesg y:设定允许别人给自己发送信息
# sync:缓存同步校验
# shutdown:关机,参数:-r重启,-h关机不重启,-f快速关机,-c取消关机
# free:查看内存
# uptime:显示系统运行时间
# df:磁盘占用空间,参数:-a显示所有文件系统
# du:磁盘使用情况
# dd:拷贝并格式转换
# fdformat:低格软盘
# echo:显示文字
# cal:日历
# date:系统日期和时间
# clear:清屏

8. 我的回忆 by tom2sun
# who:查看当前用户
# finger:查看其他用户信息
# rlogin:远程登录
# rcp:远程复制
# netstat:网络状态
# cat:一次完全显示
# more:分屏显示
# file:列出文件类型
# grep:查找内容
# find:查找文件
# ps:当前运行程序,参数-a显示所有进程
# at:时间,命令,Ctrl+D结束
# lp:打印
# nice:指定优先级
# renice:调整优先级
# kill:终止进程
# man:获取命令帮助
# touch:改变时间记录
# ln:链接
# mount -t vfat /dev/hda1 /mnt/dos:挂载Dos分区(不适用于Unix-Center)

9. FTP
# ftp:启动FTP程序
ftp>
open:打开
close:关闭
bye:离开
get:下载
put:上传
mget/mput:多个文件下载/上传
reget:恢复下载
binary:二进制传送文件
ascii:ASCII码传送
cd:改变远程目录
lcd:改变本地目录
mkdir:建目录
rmdir:删除目录
delete:删除文件
mdelete:一次删除多个
rename:重命名
status:显示状态
prompt:交互式
hash:每传送1024字节显示#(hash)
size:显示文件大小
reset:重置

10. vi
a,i:进入输入状态
ESC:返回命令状态
:命令模式
Q!:退出

11. 快键及其他
Alt+F1~F6:访问多个虚拟控制台(不适用于Unix-Center)
Tab:命令补全
末尾&:后台进程

----------------------------------------

硬件系统:

1、如何查看cpu的状态?                 
# psrinfo -v
# mpstat     可以列出多cpu负载的状态

2、如何查看内存?                       
# prtconf | grep 'Memory' 可以查看内存的多少.
# /usr/platform/sun4u/sbin/prtdiag

3、如何动态添加swap分区? # $su - root                                  -----  成为超级用户
# mkfile 100m /home/swapfile         -----  创建100m的Swap文件
# /usr/sbin/swap -a /path/filename  -----  激活Swap文件
# /usr/sbin/swap -l                 -----  验证swap文件
# /usr/sbin/swap -d /path/filename  -----  取消swap文件
# rm -rf /home/swapfile              -----  删除swap文件

4、如何查看当前网卡是以何种速率起来的?    
# dmesg |grep Link

5、如何调整x-window的分辨率和刷新频率?
  字符界面登陆,运行:#/kdmconfig

6、如何使用光、软驱?
一般情况下用:
# /etc/init.d/volmgt start
# volcheck
以上方法不行,用:
# /etc/init.d/volmgt stop
# mount -F hsfs -o ro /dev/dsk/c0t6d0s0 /cdrom --挂接光驱
# mount -F pcfs /dev/diskette0 /floppy         --挂接软驱
solaris定义系统磁盘文件系统说明:
ufs – UNIX文件系统。是Solaris缺省的文件系统。
hsfs – 高密度CD-ROM文件系统,是只读文件系统。
pcfs – PC文件系统,支持DOS格式化的软盘

7、SCSI设备的命名规则是什么?
带有总线控制器的硬盘的使用,下面列出了总线控制器的硬盘命名习惯:
cWtXdYsZ
c Logical controller number
t Physical bus target number
d Drive number
s Slice (or partition) number (0 to 7)
例如:
/dev/rdsk/c0t0d0s0 该原始接口对应第一个控制器的第一个SCSI目标地址的第一个硬盘的第一片(根)
/dev/rdsk/c0t0d0s2 该原始接口对应第一个控制器的第一个SCSI目标地址上的第一个硬盘的第三片(表示整上硬盘)

8、如何查看硬盘的使用情况?                         
# df -k      可以看到已安装的文件系统的空间大小及剩余空间大小。
# quota -v       查看用户的磁盘空间信息,如果你用quota限制了用户空间大小的话。
# du -sk *   查看目录的使用情况
# du -k | sort -n  可以迅速发现那个目录是最大的。

9、如何查看硬盘物理信息?
# format       这个命令也可以查看硬盘的类型和分区的详细情况
# iostat -E看硬盘的大小和型号
# prtvtoc /dev/rdsk/c0t0d0s0   显示某个磁盘的分区状况

10、查看系统内核命令。                          
  # isainfo        看内核的bit,
  # isainfo -kv      调整内核
# modinfo          显示可载入的模组
# prtconf          显示系统硬件配置(周边设备)
#sysdef           显示可载入的模组,硬件配置与一些可以调整的核心参考值
#ulimit -a

11、打印当前的OBP版本号                          
# prtconf –V
OBP 3.20.0 2000/10/24 10:47
# /usr/platform/sun4u/sbin/prtdiag –v | grep OBP
OBP 3.20.0 2000/10/24 10:47 POST 6.1.0 2000/10/24 10:49
ok. .version
Release 3.20 Version 0 created 2000/10/24 10:47
OBP 3.20.0 2000/10/24 10:47
POST 6.1.0 2000/10/24 10:49
OBDIAG 4.5.1 2000/10/24 10:48

12、查看及启动系统的32位或64位内核模式                      
64位模式
# isalist –v
sparcv9+vis sparcv9 sparcv8plus+vis sparcv8plus sparcv8 sparcv8-fsmuld sparcv7 sparc
# isainfo –v
64-bit sparcv9 applications
32-bit sparc applications
# isainfo –b
64
启动64位内核模式
ok. boot kernel/sparcv9/unix

32位模式
# isalist –v
sparcv8plus+vis sparcv8plus sparcv8 sparcv8-fsmuld sparcv7 sparc
# isainfo –v
32-bit sparc applications
# isainfo –b
32
启动32位模式
ok. boot kernel/unix

13、测定当前的显示器刷新频率
# /usr/sbin/fbconfig –rev \?

14、如何配置网卡ip?
# ifconfig -a             --查看网卡,例如是hme0
# ifconfig hme0  unplumb  --停止网卡
# ifconfig hme0  plumb    --起用网卡
# ifconfig hme0 inet 192.168.2.3 netmask 255.255.255.0 up  --添加ip、子网掩码
# vi /etc/defaultrouter   添加默认路由的ip
# vi /etc/hostname.hme0   添加主机名
# vi /etc/nodename        添加主机名
# vi /etc/resolv.conf    
   domain china.com          你的域名
   nameserver 202.106.0.20   你使用的nds ip
# vi /etc/nsswitch.conf     更改 hosts:file dns

15、 PROM状态命令与参数
格式:  OK>; 指令
       命令        说明
banner                     显示当前机器配置状况,CPU,内存,hostid,EtherNet
probe-scsi                 显示内部SCSI通道所挂接设备
probe-scsi-all             显示所有SCSI通道及所挂接设备
probe-ide                  显示所有IDE通道及所挂接设备(针对U10,U5)
devalias                   显示设备别名,如 cdrom,disk,disk0,disk1等
printenv                   无参数,显示环境变量或
                                    参数为环境变量名 如: printenv auto-boot?
setenv                     设置环境变量,如: setenv auto-boot? false
set-default                恢复环境变量预定值  如:set-default auto-boot?
set-defaults               恢复所有环境变量预定值
boot device option        启动主机
                        设备别名:  cdrom 或 disk
                        设备名:   /pci@1f,4000/scsi@3,1/disk@6,0:f
                        option  -r  设备配置 
                                -s  单用户
eject cdrom|floppy         弹出cdrom或floppy
reset                         复位
test net       
watch-net-all       
show-devs       

16、查找网卡名称及接口个数                          
# grep network /etc/path_to_inst

17、如何一块网卡帮定三个ip,并且子网掩码不同?
举例说明,网卡名hme0:
# vi /etc/hosts
127.0.0.1 localhost
192.168.2.1 dbs loghost
192.168.9.15 dd
192.168.9.65 aa
# vi /etc/netmasks
192.168.2.0 255.255.255.0
192.168.9.0 255.255.255.192
192.168.9.64 255.255.255.252

#vi /etc/hostname.hme0
dbs
#vi /etc/hostname.hme0:1
dd
#vi /etc/hostname.hme0:2
aa
# ipconfig hme0 inet 192.168.2..1 netmask 255.255.255.0 up 
# ipconfig hme0:1inet 192.168.9.15 netmask 255.255.255.192 up
# ipconfig hme0 inet 192.168.9.65 netmask 255.255.255.252 up
# init 6
#ipconfig -a

18、如何在prom状态下查看光纤硬盘 ?  
stop +a进入ok状态:
ok>; select 光纤卡设备名(可用show-devs查看到)
ok>; show-children

19、主机双屏幕设置。        
1.Confirm there are two Video Cards。
2.Confirm driver installed and patches installed if need。
3.vi /usr/dt/config/Xservers.
comment the last line.
and uncomment the nearest line like this.
4.reboot.

20、查看硬盘参数及其物理地址:
#format </dev/null

21、显示磁盘的分区情况:
#prtvtoc /dev/rdsk/c0t0d0s2


系统应用:

1、、查看系统运行级别
# who -r 看运行级别

2、进程工具                
pstop pid  停止进程
prun pid  重新启动进程
ptime pid  使用微状态计算进程时间
pwait pid  等待指定的进程终止
pcred pid 显示可信度    *
pfiles pid 显示已打开文件的fstat和fcntl信息   *
pflags pid 显示每个lwp的/proc跟踪标志,等待和待有信号量以及其他状态信息  *
pldd  pid 显示链接到每个进程的动态链接库   *
pmap pid  显示地址映射空间   *
psig pid 显示信号操作    *
pstack pid 显示每个lwp的十六进制与符号堆跟踪   *
ptree pid 显示包含指定PID的进程树
pwdx  pid 显示当前工作目录   *
后面加*的必须是超级用户执行。
这些工具在/usr/proc/bin/里面。

3、patch软件包的安装
每个补丁都有编号。例如补丁号为101945,版本是34的话,这个补丁的目录名就是101945-34.
# patchadd 105160-01     安装补丁
# patchrm                删除补丁
# patchadd -p            检查系统的补丁情况
# showrev -p             查看所有已经安装的patch

4、如何容许root用户远程登录?
  # vi /etc/default/login 
  CONSOLE=/dev/console  ---用#注释掉这一行。

5、如何限定telnet登陆数?solaris pts的数量缺省为47, 修改/etc/system文件, 增加如下内容:
set maxusers=数量
set pt_cnt=数量

6、显示已经使用和未使用的i-node数目        
# df –F ufs –o i

7、显示cpu使用率最高的进程                   
# ps –eo pid,pcpu,args | sort +1n
该命令输出当前系统进程的pid, CPU占用率及命令描述,并以pcpu来排序 

8、查看当前的OpenWindows版本                   
# showrev –w
OpenWindows version:
X11 Version 6.4.1 5 November 2001

9、查看当前CDE的版本                               
# /usr/ccs/bin/what /usr/dt/bin/dtmail
/usr/dt/bin/dtmail:
CDE Version 1.4.6_06
CDEVersion1.4.6_06

10、文消掉本中的^M
# cat test.dat | tr -d '\015' >; test.out
这样可以将 test.dat 内 ^M(\015) 这个字元去掉, 产生 test.out

11、关机命令。
关闭系统的方式根据关闭的原因而不同.执行关闭有的是为了转至执行等级S,有的是要停止操作系统并关闭设备的电源.
(1) /usr/sbin/shutdown –gtime –ilevel -y
(2) init 0
(3) halt
(4) STOP+A ; sync
(5) 关闭电源
紧急情况,按Stop_A , 如Stop_A不起作用,则将设备电源关闭再打开.这是
极端情况.这两种方法不是干净的关闭,是突然关闭的,仅在紧急情况使用.

12、Solaris下怎么发送即时消息?
用wirte命令到单个用户的终端。
$ wirte username
输入消息正文,结束按ctrl-d,消息就会出现在用户终端。
用户可以用mesg n[y]来决定是否启动接受消息。

用wall,是发给所有系统用户。
$ wall
hello ,i love you ...... 结束用ctrl-D.

rwall -n netgroup 给网络上所有用户。
$ rwall -n workgroup --------发给组workgroup下的每一个用户
hi ! no smoking ...... 结束用ctrl -d

$ rwall sune450 ------或者主机名为sune450。用法如上。。。

13、系统是sunos5.8, 不知何种原因现在唯一的普通用户起不了Terminal, vi等,但是超级用户可以,如何补救?          
   用/etc/skel/local.cshrc 替换掉登陆路径下的 .cshrc, 重新登陆, 就OK了!
$cp /etc/skel/local.cshrc ./

14、关机时这个题是什么意思?           
/usr/sbin/vold[724]: [ID 244572 daemon.error] 卸载 /vol 时发生问题;中断系统调用
uxwdog[481]: [ID 248799 daemon.error] error communicating with server (Broken pipe)

你还没卸下来/VOL就启动,才出问题,运行:
# umount -f /vol后再做。

15、find常用的例子:
命令格式: find dir -name filename command
例子:
# find . -name hello -print         寻找目前目录及所有的子目录内叫hello的文档。
# find . -ctime +7 -print            找出七天内未被更动的文档
# find . -size +2000m -print         找出大小超过2000 bytes的文档
# find /tmp -user b1234567 -print    在/tmp下属於b1234567的文档
# find . -name '*.c' -exec rm {}     删除所有的.c档
# find . -name test\* -print         显示当前目录及其子目录文件名前4位为test的文件名

16、忘记solarsi的root口令怎么办?              
方法一:
1.别怕 ,跟我来.
2.把你的solaris光盘放进cdrom
3.键入stop+a
4.当出现'ok'字样时,键入boot cdrom -s
5.cd /tmp
6.mkdir /tmp/xxx (xxx是什么鬼东西就无关紧要了)
7.mount /dev/dsk/c0t0d0s0 /tmp/xxx (在这里c0t0d0s0是你的root盘)
8.运行csh
9.TERM=sun;export TERM或者
setenv TERM vt220
10.cp /tmp/root/xxx/shadow /tmp/root/xxx/shadow/shadow.backup
11.vi /tmp/root/xxx/shadow并且将password里root项删除。
12.重启动,你就可以以无密码的root登陆了,这时更改你的密码。
要是没有shadow,就把/etc/passwd里root用户名后面的X删掉,就可以了
方法二:
找一台有系统的solaris机器,把忘记密码的系统放进去mount上来,重复方法一10以后的步骤.

solaris for x86的机器:
用光盘启动到要你安装的时候退出去就成单用户,剩下的操作如上。

17、常见文件的解压                   
一般而言,在solaris下,会有这么几种格式的软件:
1) .gz结尾的文件,我们用gunzip或者gzip -d来解压,再用tar来解压.
2) .tar结尾的文件,我们肯定知道用tar xvf的格式来解压.
3) .zip结尾的文件,我们用unzip,注意,这个只有在高版本的solaris下,才有.而且该文件格式以solaris的patch比较多.
4) .Z结尾的文件,我们一般用uncompress来解压(当然,每个人的习惯不一样.)
上面讲的是解压,一般解压后,会生成这么几种方式:
1)生成.local的文件,这个时候,我们用: pkgadd -d xxx.local来安装.
2) 生成一个目录,而且该目录下会有一些pkg信息,我们用: pkgadd -d . ;指在当前目录下,安装,并且按照缺省的路径来安装.
3) 生成一个数字的目录,一般是指solaris的patch,这个时候我们用patchadd来安装.

18、如何在命令行界面替换一个文件中的字符段?
# vi file 在命令模式中输入:
:1, $s/diag/peng/g 全文件查找diag并替换为peng

19、请问TERM=VT100和TERM=dtterm都在什么情况下设置?  
一般情况下如果你在机器的显示器上登陆或者通过XMANAGER等登陆,就默认是dtterm,telnet 一般是ansi,当你通过telnet修改文件的时候,需要设置成 TERM = VT100 ; export

TERM

20、如何查看系统的版本?
$ uname -X
$ more /etc/release

21、命令行进入CDE:
#/usr/dt/bin/dtlogin -daemon;exit
or
#/etc/rc2.d/S92dtlogin start;exit;

22、查看patch安装过程中返回错误代码的含义:
#more /usr/sbin/patchadd

23、如何从一台SOL8的机器登录到另外一台SOL8的CDE桌面上去。
登陆CDE的时候点击一下菜单:选择--登陆远程主机--

24、如何查看你的默认语言环境?    C.Arthur
# more /etc/default/init

25、如何更改/home的权限?  
停掉autofs服务,或者将/etc/auto_master的home注释掉:
#vi /etc/auto_master  
------------内容如下----------
# Master map for automounter
#
+auto_master
/net -hosts -nosuid,nobrowse
#/home auto_home -nobrowse
/xfn -xfn


第三方软件应用或技巧:

1、查看当前的bind版本信息                    
# nslookup –class=chaos –q=txt version.bind

2、在登录时显示系统指定的消息?
#vi /etc/motd    ----删除所有过时的消息,输入新消息
注意:对于已经登录且正在使用系统的用户不显示该消息,超过一屏的消息无法显示。每次修改该文件后,该文件的时间戳随之更新。

3、去掉文本中^M
# dos2unix aaa.txt bbb.txt,会去掉aaa.txt中的^M,生成bbb.txt文件。

4、将系统中7天前的txt文件查找并打包。
# find / -mtime -7 >;aaa.txt 
# tar cvf bbb.tar -I aaa.txt
---查找出文件记录在aaa.txt文件中,在作成bbb.tar文件包。

5、查找并删除比某一天更老的文件:
#find . ! -mtime -<days>; | /usr/bin/xarys rn -rf

6、solaris9普通用户下无法正确输入中文的解决方法:
在用户目录在#vi .profile 修改如下:
stty cs8 -istrip

7、请问如何防止telnet登陆发呆时间过长被踢呢?
这里,vi /etc/default/login
# TIMEOUT sets the number of seconds (between 0 and 900) to wait before
# abandoning a login session.
#
#TIMEOUT=300
修改之后不是立即生效,在这之后所又的login session都符合这个要求,但是在修改之前已经建立的连接不受影响。

8、如何安装gcc。
去sunfreeware.com上下载相应平台的pkg包的gcc版本。
#pkgadd -d gcc*
设置环境变量:
bash 和sh 的shell:
vi $home/.profiel
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/etc:/usr/local/bin:/usr/ccs/bin;export PATH
CC=gcc;export CC
csh的shell:
vi $home/.cshrc
set path=( /bin /usr/bin /usr/ucb /etc /usr/local/bin /usr/local/sbin .)
setenv CC gcc 

9、列出当前目录下的目录。  
ls -al | grep '^d'

10、用命令行来打开一个新的terminal。 
/usr/dt/bin/dtterm


X86或者Vmware:

1、在Solaris10 x86上挂接window98分区的方法。     
#mount -F pcfs /dev/dsk/c0d1p0:e /mnt
总结一下:
偶的硬盘是接在IDE1的slaver盘上,用上述命令可将E:盘挂在/mnt
目录下。如果你的电脑只有一个硬盘,并且是接在主板的IDE1槽,设为
Master盘(通常这种情况较多),现在想挂WIN98下的D:盘,可输入
#mount -F pcfs /dev/dsk/c0d0p0:d /mnt
注意,/mnt可以改为任意的其它空目录,如/data(我在文件管理器中自己
新建的一个目录),可改为
#mount -F pcfs /dev/dsk/c0d0p0:d /data
按回车后如没有任何出错提示,则表示挂接成功,你就可以进入挂接的文件夹(此处为/data)找到你所挂接的win98的D:分区上的文件了。
本方法经过偶N次实验,是确实可行的。为后来者不再偶走过的弯路,偶特在此总结一下,哪位初学者不会在Solaris10 x86(Solaris9也应该行)
挂win98分区的话,可参考本方法。





----------------------------------------

SysAdmin Commands

Debugging

  truss executable
/* Trace doing of given command ( useful debugging ) */ 

  truss -f -p <pid of a shell>
/* Using multiple windows, this can be used to trace setuid/setgid programs */ 

Arp, ethernet trouble shooting 

  arp -a .
/* Shows the ethernet address arp table */ 

  arp -d myhost
/* Delete a stale ethernet entry for host myhost */ 

Disk Commands 

  du -k .
/* Reports disk space used in Kilobytes */ 

  du -sk .
/* Reports only total disk space used in Kilobytes */ 

  du -sk *|sort -k1,1n
/* Reports total disk space used in Kilobytes in present directory */

  du -ad /var | sort -nr
/* Tells you how big the /var files are in reverse order */ 

  fdformat -d -U
/* Format diskette */ 

  /usr/bin/iostat -E
/* Command to display drives statistics */ 

  /bin/mount -F hsfs -o ro /dev/sr0 /cdrom
/* Mount an ISO 9660 CDROM */ 

  newfs -Nv /dev/rdsk/c0t0d0s1
/* To view the superfblocks available */ 

  prtvtoc /dev/rdsk/c0t0d0s2
/* Disk geometry and partitioning info */ 

  quot -af
/* How much space is used by users in kilobytes */ 

Driver Parameters 

  ndd /dev/ip \?
/* Shows IP variables in the kernel */ 

  ndd /dev/ip ip_forwarding
/* Tells you if forwarding is on (=1) */ 

  ndd -set /dev/ip ip_forwarding 1
/* Enables IP forwarding between interfaces */ 

File Manipulation 

  dos2unix | -ascii <filename>
/* Converts DOS file formats to Unix */ 

  split
/* Split files into pieces */ 

  [vi] : %s/existing/new/g
/* Search and Replace text in vi */ 

  [vi] :set nu
/* Set line numbers in vi */ 

  [vi] :set ts=[num]
/* Set tab stops in vi */ 

File System 

  cat /dev/null > filename
/* Zero's out the file without breaking pipe */ 

  dd if=/dev/rdsk/... of=/dev/rdsk/... bs=4096
/* Make a mirror image of your boot disk */ 

  df -k | grep dg| awk '{print $6}' |xargs -n 1 umount
/* Unmount all file systems in disk group dg */ 

  fsck -F ufs /dev/rdsk/c0t0d0s0
/* Check a UFS filesystem on c0t0d0s0 */ 

  fsck -F ufs -y /dev/rdsk/c0t0d0s0
/* Check answering yes to all questions */ 

  fsck -F ufs -o b=97472 /dev/rdsk/c0t0d0s0
/* Check using an alternate super block */ 

  gzip -dc file1.tar.gz | tar xf -
/* Unpack .tar.gz files in place */ 

  gzip -d -c tarball.tgz | (cd /[dir];tar xf - ) &
/* Unpacking tarballs to diff location */ 

  ln [-fhns] <source file> <destination file>
/* Creating hard links and soft links */ 

  ls -la | awk '{ print $5,"    ",$9 }' | sort -rn
/* File sizes of current directory */ 

  mount -f pcfs /dev/dsk/c0d0p1 /export/dos
/* Mount DOS fdisk partition from Solaris */ 

  mount -F ufs -o rw,remount /
/* Used to remount root to make it writeable */ 

  mount -o remount,logging /spare
/* Re-mount the ro file system rw and turn on ufs logging */ 

  pax -rw . /newdir
/* Efficient alternative for copying directories */ 

  prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t1d0s2
/* Cloning Partitiontables */ 

  tar cvf filename.tar
/* Create a tape (tar) archive */ 

  tar xvf filename.tar
/* Extract a tape (tar) archive */ 

  tar cf - . | (cd /newdir ; tar xf -)
/* Recursively copy files and their permissions */ 

  /sbin/uadmin x x
/* Syncs File Systems and Reboots systems fast */ 

  zcat [cpio file] | cpio -itmv
/* Show the contents of a compressed cpio */ 

  zcat <patch_file.tar.Z | tar xvf -
/* Extract the patch_file that is a compressed tar file */ 

File Transfer 

  get filename.suffix |"tar xf -"
/* Undocumented Feature of FTP */ 

  put "| tar cf - ." filename.tar
/* Undocumented Feature of FTP */ 

  find . -depth | cpio -pdmv /path/tobe/copied/to
/* Fast alternative to cp -pr */ 

  sendport
/* Transferring large numbers of files within the same ftp control session */ 

General 

  /usr/bin/catman -w
/* Create windex databases for man page directories */ 

  FQ_FILENAME=<fully_qualified_file_name>; echo ${FQ_FILENAME%/*}
/* Extract directory from fully-qualified file name. */ 

  mailx -H -u <username>
/* List out mail headers for specified user */ 

  set filec
/* Set file-completion for csh */ 

  uuencode [filename] [filename] | mailx -s "Subject" [user to mail]
/* Send files as attachments */ 

Hardware 

  cfgadm
/* Verify reconfigurable hardware resources */ 

  m64config -prconf
/* Print M64 hardware configuration */ 

  m64config -depth 8|24
/* Sets the screen depth of your M64 graphics accelerator */ 

  m64config -res 'video_mode'
/* Change the resolution of your M64 graphics accelerator */ 

Kernel 

  /usr/sbin/modinfo
/* Display kernel module information */ 

  /usr/sbin/modload <module>
/* Load a kernel module */ 

  /usr/sbin/modunload -i <module id>
/* Unload a kernel module */ 

  nm -x /dev/ksyms | grep OBJ | more
/* Tuneable kernel parameters */ 

  /usr/sbin/sysdef
/* Show system kernal tunable details */ 

Memory 

  prtconf | grep Mem
/* Display Memory Size */ 

Network Information 

  ndd /dev/arp arp_cache_report
/* Prints ARP table in cache with IP and MAC address */ 

  netstat -a | grep EST | wc -l
/* Displays number active established connections to the localhost */ 

  netstat -k hme0
/* Undocumented netstat command */ 

  netstat -i
/* Show the TCP/IP network interfaces */ 

  netstat -np
/* Similar to arp -a without name resolution */ 

  netstat -r
/* Show network route table */ 

  netstat -rn
/* Displays routing information but bypasses hostname lookup. */ 

  netstat -a | more
/* Show the state of all sockets */ 

  traceroute <ipaddress>
/* Follow the route to the ipaddress */ 

Network/Tuning 

  ifconfig eth0 mtu 1500
/* Change MTU of interface */ 

  ifconfig eth0 10.1.1.1 netmask 255.255.255.255
/* Add an Interface */ 

  /sbin/ifconfig hme0:1 inet 10.210.xx.xxx netmask 255.255.0.0 broadcast 10.210.xxx.xxx
/* Virtual Interfaces */ 

  /sbin/ifconfig hme0:1 up
/* Bring virtual interface up */ 

  /usr/sbin/ndd -set /dev/hme adv_100fdx_cap 1
/* Nailling to 100Mbps */ 

  ndd -set /dev/ip ip_addrs_per_if 1-8192
/* To set more than 256 virtual ip addresses. */ 

  ndd -set /dev/tcp tcp_xmit_hiwat 65535
/* Increase TCP-transmitbuffers */ 

  ndd -set /dev/tcp tcp_recv_hiwat 65535
/* Increase TCP-receivebuffers */ 

Processes 

  fuser -uc /var
/* Processes that are running from /var */ 

  kill -HUP `ps -ef | grep [p]roccess | awk '{print $2}'`
/* HUP any related process in one step */ 

  lsof -i TCP:25
/* Mapping port with process */ 

  pfiles <pid>
/* Shows processes' current open files */ 

  pkill -n <name>
/* Kill a process by name */ 

  kill `ps -ef | grep program_name | grep -v grep | cut -f8 -d ' '`
/* pkill for solaris 2.6 */ 

  prstat -a
/* An alternative for top command */ 

  /usr/ucb/ps -aux | more
/* Displays CPU % usage for each process in ascending order */ 

  /usr/ucb/ps -auxww | grep <process name>
/* Gives the full listing of the process (long listing) */ 

  ps -ef | grep -i <string> | awk '{ print $2 }'
/* Creates list of running PID by */ 

  ps -ef | grep -v "0:00" | more
/* Gives you a list of any process with CPU time more than 0:00 */ 

  ps -ef | more
/* Show all processes running */ 

  ps -eo pid,args
/* List processes in simplified format */ 

  ps -fu oracle|grep pmon
/* See which instances of Oracle are running */ 

  /usr/proc/bin/ptree <pid>
/* Print the parent/child process 'tree' of a process */ 

  /usr/proc/bin/pwdx <pid>
/* Print the working directory of a process */ 

  top -b 1
/* Returns the process utilizing the most cpu and quits */ 

Resource Management 

  /usr/bin/ldd [filename]
/* List the dynamic dependencies of executable files */ 

  /usr/proc/bin/pmap pid
/* Report address space map a process occupies */ 

Route Configuration 

  route add net 128.50.0.0 128.50.1.6 1
/* Adds route to 128.50 network via 128.50.1.6 */ 

  route change 128.50.0.0 128.50.1.5
/* Changes the destination address for a route */ 

  route delete net 128.50.0.0 128.50.1.6
/* Deletes route to 128.50 network */ 

  route get [hostname]
/* Which interface will be used to contact hostname */ 

  route monitor
/* Monitors traffic to the routes */ 

  route flush
/* Removes all entries in the route table */ 

Searching Items 

  egrep "patterna|patternb" <filename>
/* Search for multiple patterns within the same file */ 

  find . -exec egrep -li "str" {} \;
/* Find a string in files starting cwd */ 

  find / -fstype nfs -prune -o fstype autofs -prune -o -name filename -print
/* Find without traversing NFS mounted file systems */ 

  find . -mtime -1 -type f
/* Find recently modified files */
 
  find / -mtime <# of days>
/* Find files modified during the past # of days */

  find . ! -mtime -<days> | /usr/bin/xargs rm -rf
/* Finds and removes files older than <days> specified */ 

  find . -type f -exec grep "<sub-string>" {} \; -print
/* Find files (and content) containing <sub-string> within directory tree */ 

  find . -type f -exec grep -l "<sub-string>" {} \;
/* Find filenames containing <sub-string> within directory tree */ 

  find . -type f -print | xargs grep -i [PATTERN]
/* Recursive grep on files */ 

  find / -user <username>
/* Find all files owned by <username> */ 

  find / | grep [file mask]
/* Fast way to search for files */ 

  find <start_path> -name "<file_name>" -exec rm -rf {} \;
/* Recursively finds files by name and automatically removes them */ 

  find /proc/*/fd -links 0 -type f -size +2000 -ls
/* Find large files held open by a process */ 

  ls -lR | grep <sub_string>
/* Fast alternative to find */ 

Security 

  echo 'Please go away' > /etc/nologin
/* Stops users logging in */ 

  find / -perm -0777 -type d -ls
/* Find all your writable directories */ 

  find / -type f -perm -2000 -print
/* Find all SGID files */ 

  find / -type f -perm -4000 -print
/* find all SUID files */ 

Set Terminal Options 

  stty erase ^H
/* Sets the Backspace Key to erase */ 

  stty erase ^?
/* Sets the Delete Key to erase */ 

  stty sane
/* Rreset terminal after viewing a binary file. */ 

  tput rmacs
/* Reset to standard char set */ 

Snoop Your Network 

  snoop -d pcelx0
/* Watch all network packets on device pcelx0 */ 

  snoop -o /tmp/mylog pcelx0
/* Saves packets from device pcelx0 to a file */ 

  snoop -i /tmp/mylog host1 host2
/* View packets from logfile between host1 & host2 */ 

  snoop -i /tmp/mylog -v -p101
/* Show all info on packet number 101 from a logfile */ 

  snoop -i /tmp/mylog -o /tmp/newlog host1
/* Write a new logfile with all host1 packets */ 

  snoop -s 120
/* Return the first 120 bytes in the packet header */ 

  snoop -v arp
/* Capture arp broadcasts on your network */ 

Swap File 

  mkfile -v 10m /export/disk1/myswap
/* Makes a 10 Megabyte swapfile in /export/disk */ 

  mkfile -nv 10m /export/disk1/myswap
/* Makes an empty 10 Megabyte swapfile */ 

Swap Space 

  swap -s
/* List the amount of swap space available, also see mkfile */ 

  swap -a /export/disk1/swapfile
/* Add a swapfile */ 

  swap -d /dev/dsk/c0t0d0s4
/* Deletes a swap device */ 

  swap -l
/* List the current swap devices */ 

System Configuration 

  drvconfig ; disks
/* Adding hot-plug disks to system */ 

  /usr/sbin/eeprom auto-boot? false
/* Changes eeprom autoboot? setting without going to Ok prompt */ 

  /usr/sbin/eeprom diag-switch? true
/* Set the system to perform diagnostics on the next reboot. */ 

  /usr/sbin/eeprom local-mac-address?=true
/* Multiple Port Network Card Setting */ 

  /usr/sbin/grpck
/* Check /etc/group file syntax */ 

  /usr/sbin/pwck
/* Check /etc/passwd file syntax */ 

  /usr/sbin/sys-unconfig
/* Clear host specific network configuration information */ 

System Information and Monitoring 

  coreadm -e log
/* Report global core */ 

  /bin/echo "0t${stamp}>Y\n<Y=Y" | adb
/* Convert UNIX timestamp to something human-readable */ 

  /usr/sbin/eeprom
/* Show eeprom parameters */ 

  grep "\-root" /var/adm/sulog | grep -v \+ | tail -25
/* List most recent attempts to switch to superuser account. */ 

  isainfo -bv
/* Quickly checkout if machine is in 32 or 64 bit mode */ 

  last
/* Tells who was or still is on the system */ 

  logger -i
/* Log the process ID */ 

  psradm -f [processor id]
/* Take processor offline */ 

  /usr/sbin/prtconf -vp
/* Show system configuration details */ 

  /usr/platform/`/bin/uname -i`/sbin/prtdiag -v
/* System Diagnostics */ 

  prtconf -pv | grep banner-name |awk -F\' ' { print $2 } ' | head -1
/* Show actual model name of machine */ 

  psrinfo | wc -l
/* Display number of processors */ 

  sar -A <time in sec>
/* Provides cumulative system report. */ 

  sar -a <time in sec>
/* Report use of file access system routines. */ 

  sar -u
/* Report CPU Utilization */ 

  telnet <remote machine> 13 | grep ':'
/* Get the time on remote Unix machine */ 

  uname -a
/* Displays system information */ 

  vmstat 10
/* Displays summary of what the system is doing every 10 seconds */ 

  who -b
/* Displays the date of the last system reboot. */ 

  ypcat hosts | sort -n -t. +0 -1 +1 -2 +2 -3 +3 -4
/* Take the input of "ypcat hosts" or "cat /etc/inet/hosts" and sort by IP. */





ok>;show-devs
ok>;show-disks

终端控制
ctrl+s :终止屏幕输出,如用cat命令输出时,要停一下
ctrl+q :恢复ctrl+q的输出
ctrl+c :中断当前的活动,返回命令提示符
ctrl+d :表示文件的结束或退出,如退出终端窗口
ctrl+u :擦除整个命令行
ctrl+w :擦除命令行最后一个单词
ctrl+h :擦除命令行最后一个字符
bc :计算器



#ksh 切换到k shell
  

命令:



# uname
SunOS
NAME

#man uname
     uname - print name of current system

SYNOPSIS
     uname [-aimnprsvX]

     uname [-S system_name]
# date
2004年05月19日 星期三 21时57分49秒 CST
#
stings
$stings /usr/bin/cat
能够用来打印可执行文件或二进制文件中的可读字符。

cat  more
 
#cat -n test.txt             //显示行号

键值 目的
空格 滚动到下一屏
回车 一次滚动一行
b 向后移动一屏
f 向前移动一屏
h 显示更多特性的帮助菜单
q 退出,返回shell提示符
/string 向前搜索字符串string
n 查找下一处匹配

less
#less test.txt      //前移动一屏F,后B ,/string   查找字符

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 kern.info] sd0 is /pci@0,0/pci-ide@7,1/ide@1/sd@0,0
Oct  6 00:20:26 wing pcplusmp: [ID 637496 kern.info] pcplusmp: fdc (fdc) instance 0 vector 0x6 ioapi
c 0x1 intin 0x6 is bound to cpu 0
Oct  6 00:20:26 wing last message repeated 1 time
Oct  6 00:20:26 wing isa: [ID 202937 kern.info] ISA-device: fdc0
Oct  6 00:20:26 wing fdc: [ID 114370 kern.info] fd0 at fdc0
Oct  6 00:20:26 wing genunix: [ID 936769 kern.info] fd0 is /isa/fdc@1,3f0/fd@0,0
Oct  6 00:20:30 wing i8042: [ID 526150 kern.info] 8042 device:  mouse@1, mouse8042 # 0
Oct  6 00:20:30 wing genunix: [ID 936769 kern.info] mouse80420 is /isa/i8042@1,60/mouse@1
Oct  6 00:21:37 wing login: [ID 722452 auth.error] user2netname: (nis+ lookup): Error in accessing N
IS+ cold start file... is NIS+ installed?
Oct  6 00:21:47 wing last message repeated 1 time
Oct  6 00:52:07 wing login: [ID 722452 auth.error] user2netname: (nis+ lookup): Error in accessing N
IS+ 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        //进行细致的比较生成一个差别表

touch
#touch test1.txt test2.txt test3.txt    //可以一次创建多个文件

mkdir
#mkdir /export/home/wing
#mkdir -p /export/home/wing //在路径中名中不存在的目录将被创建
#rmdir dir   //所要删除的目录必须是空的

rm
rm -i  test.txt test2.txt  //交互式删除文件
rm -r  /tem/testd   //删除目录和目录下的文件
rm -ir /tem/testd  //交互式的删除目录和目录下的文件

cp
cp -i  oldfilename newfilename   //交互式拷贝
cp /export/home/keven/ok.txt /export/home/wing/test.txt
cp -ri /export/home/keven /export/home/wing  整个目录一起拷
cp -rp  文件属性一起拷贝


crontab
直接登陆窗口界面
# crontab -l root   //查看作业
/etc/init.d/cron stop    //停止进程
在CONSOLE 中熟命令 crontab -e root
crontab -e root     //编辑加入要执行的代码
0-59 * * * * date >;>; /export/home/keven/keven.txt //加入次行在末尾,每分钟执行一次

“格式如下:
  (1)  (2)  (3)  (4)  (5)  (6)
   0   0   *   *   3   date >;>; /export/home/keven/keven.txt
      1. 分钟 (0-60)
      2. 小时 (0-23)
      3. 日 (1-31)
      4. 月 (1-12)
      5. 星期 (0-6)
      6. 所要运行的程序
如1-59分钟,1-24 小时

0 18-23 0 0  0-6   //每天的18-23点执行,0-6为周日到周六

/etc/init.d/cron start  //启动进程
# crontab -l root 
查看作业是否加入执行队列。
不行退出到登陆界面,再次登陆进入,还加载就reboot


你是不是直接编辑用户的cron文件呀?
如果是当然不运行,cron demon是在启动的时候才读一次配置文件.
如果你是后加的JOB 要用crontab -e来编辑用户的cron.
要不你 kill -HUP cron的进程ID.
重新启动这个进程.
每5分钟做一次必须写成5,15,20,25,30,35,40,45,50,55 * * * *
===================================
“格式如下:
  (1)  (2)  (3)  (4)  (5)  (6)
   0   0   *   *   3   /usr/bin/updatedb
      1. 分钟 (0-60)
      2. 小时 (0-23)
      3. 日 (1-31)
      4. 月 (1-12)
      5. 星期 (1-7)
      6. 所要运行的程序
但是我设成 1 0 0 0 0 /usr/bin/ps
希望能自动在一分钟之后显示进程。但是没有成功。
HELP ME

===============================================
15 1 * * * /opt/bin/ta.sh /opt/aadir >; /dev/null

此处>;/dev/null 必须用吗? 何意思?
输出重定向到/dev/null, 否则会mail到你的邮箱
dev/null 是一个特殊文件,所有输入到该文件的数据都会被丢弃。
>; /dev/null 的意思就是丢弃所有的输出内容,否则(就象楼上老兄说的)就会将输出内容发送到执行该命令的用户信箱中。
这种写法只能把标准输出送到/dev/null中,如果有错误产生的话,还是会送到信箱里的。下面的写法才可以丢弃所有的输出内容:
15 1 * * * /opt/bin/ta.sh /opt/aadir >; /dev/null 2>;&1

0 14 * * 0-6  //每天的下午14点执行



ls
$ 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.txt
drwxr-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.txt
drwxr-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 -F
accept*           gsscred*          metaset*           i86/  //目录
acctadm*          halt*             metastat*         roleadd*
add_drv*          hostconfig*       metasync*         test.txt  //ASCII
cachefslog@       in.rlogind*       mount*            rtquery*
cachefswssize@链接文件    in.routed*        mountall*         rwall*//可执行文件




$ ls -R   //递归显示
.:
TT_DB       keven       temp        user2       www
cole        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       www
cole        lost+found  user1       wing
$ ls -i test.txt test1.txt  //节点检查
        64 test.txt           65 test1.txt

$ ls -il test.txt test1.txt
        64 -rw-r--r--   1 keven    sysadmin      27 10月 12 17:27 test.txt
        65 -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.txt
passwd.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目录
如果文件有多个指向它的硬盘链接,只是删除该文件并不能有效的释放磁盘空间,你将不得不删除掉所有指向它的硬链接。

#ln -s src target 
是软链接,存储的只是路径,用ls -l 可以看到,如果原文件已移走或删除,该名,则target就没有用了,删除和该名链接同样用rm


如果文件有多个指向它的硬盘链接,只是删除该文件并不能有效的释放磁盘空间,你将不得不删除掉所有指向它的硬链接。

# ln -s /export/home/ddd  /var   既把/export/home/ddd目录链接到/var下面
在var下面生成ddd 链接符号。当/var满了是时候用


mv
#mv -i oldfilename newfilename 改名文件或文件夹
#mv -i source_file(s)  target_directory   移动文件到其它目录


swap             
# swap -s      //列出一个系统虚拟交换空间的摘要。

total: 25728k bytes allocated + 6140k reserved = 31868k used,56496k
available
                           
# swap -l     //列出系统物理交换空间的详细说明。
swapfile              dev      swaplo      blocks      free
/dev/dsk/c0t3d0s1   32,28        8        98792       90384

vmstat  //查看虚拟内存状态
# vmstat
kthr      memory            page            disk          faults      cpu
r b w   swap  free  re  mf pi po fr de sr cd f0 s0 --   in   sy   cs us sy id
0 0 0 635012 40880  10  36 21  0  1  0 231 3  0  0  0  116  287  184  1  1 99

# vmstat -s
        0 swap ins
        0 swap outs
        0 pages swapped in
        0 pages swapped out
    84899 total address trans. faults taken    //地址解析错误
     5916 page ins
        6 page outs
    12283 pages paged in
        9 pages paged out
    22759 total reclaims
    22759 reclaims from free list
        0 micro (hat) faults
    84899 minor (as) faults     //小错误
     5186 major faults          //主要错误
    16092 copy-on-write faults    //写复制操作错误
    22331 zero fill page faults
   539644 pages examined by the clock daemon
       18 revolutions of the clock hand
      570 pages freed by the clock daemon
      550 forks
       17 vforks
      514 execs
   431543 cpu context switches
   272891 device interrupts
   105553 traps
   671500 system calls
    97227 total name lookups (cache hits 96%)
     1297 user   cpu
     1388 system cpu
   230813 idle   cpu
     1542 wait   cpu
#

mpstat       //系统负载cpu等信息
# mpstat 5      //每隔5秒刷新一次
CPU minf mjf xcal  intr ithr  csw icsw migr smtx  srw syscl  usr sys  wt idl
  0   32   2    0   114   68  181    5    0    1    0   263    0   1   1  98
  0    2   0    0   101   55  160    1    0    0    0    58    0   0   0 100
  0    0   0    0   101   55  164    1    0    0    0    70    0   0   0 100
  0    0   0    0    99   52  158    1    0    0    0    48    0   0   0 100
  0   22   0    0   102   56  164    1    0    0    0   136    0   0   0 100




cal
# cal
   2004年  5月
日 一 二 三 四 五 六
                   1
2  3  4  5  6  7  8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31
   
# cal 12 2002           //显示2002年10月的日历
   2002年 12月
日 一 二 三 四 五 六
1  2  3  4  5  6  7
8  9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31


# date;uname                 //组合命令,中间用;隔开
2004年05月19日 星期三 22时05分23秒 CST
SunOS


重定向输入/输出
#command >;filename     //如果文件名存在,它将被覆盖,不存在将被创建
#command >;>;filename    //向一个存在的文件追加(添加到文件的末尾)内容,而不是覆盖它,如果不存在就创建。
#command 2>;filename    //重定向标准错误,会创建文件或覆盖原有文件
#commanf 2>;>;filename   //重定向标准错误,向一个存在的文件追加(添加到文件的末尾)内容,而不是覆盖它,如果不存在就创建。

建ok文件 写入:cole how are you
$ write cole<ok
cole会收到这段话:
        在 wing (pts/2) [ 10月  3 五 22:41:08 ] 上面的 wing 中的消息 ...
how are you my baby
<结束>


find
#find . -name test.txt            //搜索当前目录
#find dir -name test.txt
#find / -name test.txt
#find /export/home -name test.txt
#find ~ -name ‘*tif’                     //用户的主目录
#find /export -name core -exec rm {} \     //搜索core文件并删除它们
#find dir -type d                           //文件类型
#find /export -type d -name test           //文件夹名为test
#find /export -size  +400                   //文件大于400块的512byte =1 blocks
#find /export -name test.txt -exec rm {} \;  //查找并删除
#find /export -name test.txt -ok rm {} \;    //交互模式删除 y
#find /export -user keven                     //按用户查找
#find / -user UID -exec rm{} \;              //查找该用户的文件并删除
#find / -name pfile -print>;find.txt 2>;null.txt&
              //找到则放入find.txt,否则就放到null.txt 程序在后台运行

# find /export -name tex.txt -exec rm {} \;     //{} \中间有一个空格
$ find ~ -name ’*es’        //es的前面为任意字符


搜索表达式 意义 定义
name filename 文件名 搜索所有匹配的给定的文件,可以接受元字符(如? *)
type filetype 文件类型 搜索匹配给定文件类型的文件(d为目录)
mtime [+|-]n 修改的时间 搜索所有修改时间或者大于,或小于给定时间的文件
atime[+|-]n 访问的时间 搜索所有访问时间或者大于,或者小于给定时间的文件
user loginid -group groupid 用户ID和属组ID 搜索所有匹配登陆ID的所有者或属组ID的文件
perm mode 权限 搜索所有匹配给定权限的文件(只允许八进制模式)
size[+|-]n[c] 搜索所有大小或者大于,小于n的文件,n以512字节每块计算,如果后面有ac,则以字符(字节)计算
-print 基将搜索结果输出到标准输出。该结果是一个全路径名的文件名 列表

-exec command{}\; exec选项必须通过\;来终止;这样使得find命令可以应用于指定命令中搜索准则中给出的每个文件
-ok command{}\; -exec的交互格式.这个选项用于要求来自用户的输入命令.如 rm -i
-ls 使用长列表格式打印当前路径.这个表达式最常用于链接一个输出,把它重定向到一个文件中,以便稍后进行检查




#grep root /etc/passwd       //在passwd中查找root
#grep -i root /etc/passwd        //忽略大小写
#grep -v root /etc/passwd        //显示除了含有root的行
# grep -c root group           //统计有多少行
10

# grep -l root passwd group hosts   //查找文件中包含root的文件
passwd
group



正则表达式 功能 例子 结果
.(dot) 匹配任意字符可以多次使用,类似ls命令 grep chap.. file 显示所有包含chap,且之后还有两个字符的行
*(asterisk) 在模式上匹配0个或多个字符 grep chap*  file 显示所有包含chap,且之后可以是任意字符
\(back slash) 告诉shell按照字面意思理解\之后的特殊字符 grep dollar\* file 显示所有包含dollar*的行./告诉shell按照字面意思理解*,而不是通配符
^ (caret) 匹配所有以指定模式打头的所有行 grep ^name file 显示所有以Name开头的行
$ 匹配所有以指定模式结尾的行 grep $800 file 显示所有以800结尾的行
[] 匹配模式中的一个字符 grep [64.128] 显示所有包含64MB或128MB的行
-i 忽略大小写
-v 反包含.除了该字符串之外的行


egrep
# egrep 'N(e|o)' /etc/passwd    //查找以字母大N开头后面接e 或者o
listen:x:37:4:Network Admin:/usr/net/nls:
nobody:x:60001:60001:Nobody:/:
noaccess:x:60002:60002:No Access User:/:
nobody4:x:65534:65534:SunOS 4.x Nobody:/:


$ egrep ’(Network|uucp) Admin’ /etc/passwd
uucp:x:5:5:uucp Admin:/usr/lib/uucp:
nuucp:x:9:9:uucp Admin:/var/spool/uucppublic:/usr/lib/uucp/uucico
listen:x:37:4:Network Admin:/usr/net/nls:






sort
#cat test.txt
oggg
aaa
ddkk
ddgfg
kk
11
34
22
#sort test.txt
11
22
34
aaa
ddgfg
ddkk
kk
oggg
# ls -ld t* >;list
# cat list
-rw-r--r--   1 keven    user          32 10月  2 07:51 test.txt
-rw-r--r--   1 keven    user           0  9月 30 08: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
# sort -rn +4 list -o tt.txt        //翻转排序 头4个字符
# ls
list      ok.txt    ss        test.txt  test1     test2     test3     tt.txt
# cat tt.txt
-rw-r--r--   1 keven    user          32 10月  2 07:51 test.txt
-rw-r--r--   1 keven    user           0  9月 30 08:54 test3
-rw-r--r--   1 keven    user           0  9月 30 08:54 test2
-rw-r--r--   1 keven    user           0  9月 30 08:54 test1
#sort +5M +6n list -o up.txt

选项 描述
-n 进行数字排序,n可以单独和短横线连接,或者可以跟着一个区域参数
(+|-)n 以第n个分隔符的区域开始或结束。默认的分割符是空格
-r 翻转排序的顺序。r可以单独与短横线连用,或者可以跟着一个区域参数
-f 在排列中忽略大小写
+nM 把开始的三个字符做为月份名称的简写来排序
-d 使用字典排序,只用字母和空格排序,其它的符号忽略
-o filename 把所有输出放到文件名中


who
# who
root       console      10月  2 19:23   (:0)     (本地登陆)
wing       pts/2        10月  2 19:22   (192.168.0.1)(远程登陆)

# who -q    //登陆用户统计
root     wing
# users=2

# who -r            //运行级别
   .       run-level 3  10月  2 19:20     3      0  S

$ who -Hu
NAME       LINE         TIME          IDLE    PID  COMMENTS
keven      pts/2        10月 12 10:57   .      389      (192.168.0.1)
user       pts/3        10月 12 10:16  0:52    368      (192.168.0.1)
PID为用户登陆上来的进程,#kill -9 368 把此用户踢出

$ who
root       console      10月  3 19:21   (:0)
keven      pts/6        10月  3 22:11   (192.168.0.1)
wing       pts/2        10月  3 22:11   (192.168.0.1)
cole       pts/3        10月  3 22:11   (192.168.0.1)

w
$w
下午11点01分     运行  3:43,  4 users,  平均负载:0.00, 0.00, 0.02
用户名   终端号         登入时间       闲置   JCPU   PCPU  执行命令
root     console      下午 7点21分     3:40     10      1  /usr/dt/bin/dtscreen -mode blank
keven    pts/6        下午10点11分                         -csh
wing     pts/2        下午10点11分        5                w
cole     pts/3        下午10点11分       50                -ksh
$ w keven
下午11点10分     运行  3:52,  4 users,  平均负载:0.00, 0.00, 0.02
用户名   终端号         登入时间       闲置   JCPU   PCPU  执行命令
keven    pts/6        下午10点11分        9                -csh


logins
# logins
root            0       other           1       Super-User
daemon          1       other           1
bin             2       bin             2
sys             3       sys             3
adm             4       adm             4       Admin
uucp            5       uucp            5       uucp Admin
nuucp           9       nuucp           9       uucp Admin
smmsp           25      smmsp           25      SendMail Message Submission Program
listen          37      adm             4       Network Admin
lp              71      lp              8       Line Printer Admin
wing            1001    adm             4       my wife
keven           1002    user            100
user1           1003    adm             4
user2           1004    adm             4
cole            1005    adm             4
nobody          60001   nobody          60001   Nobody
noaccess        60002   noaccess        60002   No Access User
nobody4         65534   nogroup         65534   SunOS 4.x Nobody


last
$ last         //当前系统的使用历史使用模式
keven     pts/2       192.168.0.1      Mon Oct  6 00:55 仍在登录状态
cole      pts/6       192.168.0.1      Mon Oct  6 00:52 仍在登录状态
root      console     :0               Mon Oct  6 00:44 仍在登录状态
wing      pts/3       192.168.0.1      Mon Oct  6 00:21 仍在登录状态
keven     pts/2       192.168.0.1      Mon Oct  6 00:21 - 00:55  (00:34)
reboot    system boot                  Mon Oct  6 00:20
keven     pts/2       192.168.0.1      Sun Oct  5 19:47 - 20:02  (00:14)
reboot    system boot                  Sun Oct  5 19:46
wing      pts/1       192.168.0.1      Sun Oct  5 07:47 - 07:48  (00:00)
keven     pts/1       192.168.0.1      Sun Oct  5 06:24 - 07:47  (01:23)
root      console     :0               Sun Oct  5 06:22 - 07:48  (01:25)
keven     pts/1       192.168.0.1      Sun Oct  5 06:21 - 06:24  (00:02)
reboot    system boot                  Sun Oct  5 06:21
cole      pts/6       192.168.0.1      Sun Oct  5 01:58 - 03:09  (01:11)
wing      pts/5       192.168.0.1      Sun Oct  5 01:58 - 03:10  (01:11)

finger
# finger
Login       Name               TTY         Idle    When    Where
root     Super-User            console          Thu 19:23  :0
wing     my wife               pts/2            Thu 19:22  192.168.0.1
$ finger -s keven      //指定查看的用户
Login       Name               TTY         Idle    When    Where
keven       admin            pts/6         11 Fri 22:11  192.168.0.1
$ finger @www      //查看一台主机的登陆用户状况www为主机名
[www]
Login       Name               TTY         Idle    When    Where
root     Super-User            console        1 Fri 19:21  :0
keven    admin                 pts/6         13 Fri 22:11  192.168.0.1
#finger -s username@hostname
#finger  @webserver.com
#finger username@webserver.com
$ finger -l keven            //长格式显示
Login name: keven                       In real life: admin
Directory: /export/home/keven           Shell: /bin/ksh
On since Oct 12 10:16:41 on pts/2 from 192.168.0.1
24 seconds Idle Time
No unread mail
No Plan.
# finger user1
Login name: user1                       In real life:
Directory: /export/home/wing            Shell: /bin/sh
On since Oct 12 11:11:33 on pts/3 from 192.168.0.1
4 minutes 8 seconds Idle Time
No unread mail
No Plan.

$ finger -m   //只搜索登陆的用户名


# man -l uname     //输出该命令的地址
uname (1)       -M /usr/share/man
uname (2)       -M /usr/share/man


NAME
     man - find and display reference manual pages

SYNOPSIS
     man [-] [-adFlrt] [-M path] [-T macro-package]  [-s section]
     name...

     man [-M path] -k keyword...

     man [-M path] -f file...

id
# id
uid=0(root) gid=1(other)   //为当前用户的ID,而不是原始登陆ID

who i am                   
# who i am                      //真实的UID
root       console      Oct  2 19:23    (:0)
wing       pts/2        Oct  2 19:41    (192.168.0.1)

df -k
# df -k
Filesystem            kbytes    used   avail capacity  Mounted on
/dev/dsk/c0d0s0        63127   36137   20678    64%    /
/dev/dsk/c0d0s6      1201014  768820  372144    68%    /usr
/proc                      0       0       0     0%    /proc
mnttab                     0       0       0     0%    /etc/mnttab
fd                         0       0       0     0%    /dev/fd
/dev/dsk/c0d0s3        55047   25063   24480    51%    /var
swap                  608948      24  608924     1%    /var/run
swap                  609216     292  608924     1%    /tmp
/dev/dsk/c0d0s5        24239      15   21801     1%    /opt
/dev/dsk/c0d0s7      2691830     112 2637882     1%    /export/home
/dev/dsk/c0d0s1       462639  306816  109560    74%    /usr/openwin
du -k
#du -k /export   //递归显示文件夹中的文件或文件夹
# du -sk  /etc    查看目录的使用情况 总树统计
# du -k  /etc         逐个查看
# du -k /export | sort -n 可以迅速发现那个目录是最大的。


vi
vi(文本输入模式)
命令 功能
a 在光标后追加文本
A 在行末追加文本
i 在光标前追加文本
o 在光标下插入新的一行
vi(末行模式)
命令 功能
:w 写缓冲区,保存更改继续在vi中工作
:w new_filename 把缓冲区写如new_filename
:wq  或 ZZ 写缓冲区,保存修改,然后退出vi
:q! 不保存修改而退出
:wq! 写缓冲区保存修改然后推出vi,如果你是文件的所有者将忽略只读属性
e! 取消自上次保存以来所做的修改
:x 等价于:wq!  wq
u 取消最近的一次编辑

vi(命令模式)
命令 功能
j(或向下箭头) 向下移动一行
k(或向上箭头) 向上移动一行
h(或向左箭头) 向后移动一个字符
l(或向右箭头) 向前移动一个字符
空格 向右移动一个字符
w 向前移动一个单词(包括标点)
b 向后移动一个单词(包括标点)
$ 移动到行末
0(零)或 ^ 移动到行首
回车 移动到下一行首

vi(命令模式和末行模式)
命令 功能
x (小写) 删除光标处字符
dw 删除单词
3dw 删除三个单词
dd 删除光标所在的行
3dd 删除三行
yy 拉出一行拷贝,放到剪贴板中
p(小写) 把拉出行放到当前之下
P(大写) 把拉出行放到当前之上
:set nu 显示行号
:set nonu 隐藏行号
:set showmode 显示当前操作模式(如用vedit将自动打开)
:set noshowmode 关闭模式显示
:set  显示所有vi变量
:set all 显示所有可能的vi变量和它们的当前的值
G 到达文件的最后一行
:21 到达第21行
/string 向前搜索字符串string
?string 向后搜索字符串string
n 查找匹配的下一个字符串


cpio

#cpio -idcmv < lnx_902_disk1.cpio   截压缩

tar
# tar cvf backup.tar list ok.txt test.txt    //备份生成backup.tar
a list 1K
a ok.txt 1K
a test.txt 1K
#tar rvf backup.tar tt.txt          //追加tt.txt到backu.tar中去
# tar cvf backup.tar tt.txt        //注意会覆盖backup.tar原有的文件
a tt.txt 1K
# tar cvf /export/home/wing/mywife.tar ok2.txt ss // 备份到另一个目录
# tar xvf backup.tar              //全部还原出来

# tar xvf backup.tar tt.txt        //把指定的文件还原出来
tar: 块大小 = 4
x tt.txt, 290 bytes, 1 tape blocks
# tar tvf backup.tar          //查看里面被压缩了的文件名,并没有解压出来
tar: 块大小 = 4
-rw-rw-rw- 1002/1      290 2003 10月  3 02:10 tt.txt
$tar uf myarch mydir         //t a r将比较每个存档文件和用户目录中文件的最近更新时间,然后将任何自从上次存档以来所改变的文件拷贝到档案中


参数 说明
c 创建一个新的tar文件
t 列出tar文件的内容
x 从tar文件中解压出指定的文件
r 向已有的tar文件追加一个新文件进去
f 指定文件名
v 详细模式
m 将在从一个档案中抽取文件时,不要给它新的时戳


compress
# compress -v kk.txt mm.txt
kk.txt: 压缩:58.18% -- 用kk.txt.Z替换  //注意原来的文件将被.Z所替代
mm.txt: 压缩:1.33% -- 用mm.txt.Z替换
# ls
err.txt     kk.txt.Z    mm.txt.Z  tt.txt
# uncompress -v ok2.txt.Z    //解压缩,注意原来的.Z文件将被ok2.txt替代
# uncompress -c test1.Z|more  //只是查看文件的内容,没有解压出来

zip
#zip winzip test1.txt test2.txt     //生成winzip.zip文件
#unzip winzip.zip                   //解压缩







gzip
# gzip -v test2 test3
test2:            0.0% -- replaced with test2.gz//注意把原来的给替换了
test3:            0.0% -- replaced with test3.gz
# ls
test2.gz    test3.gz   

gunzip
#gunzip test2.gz

gzcat
#gzcat tt.txt.gz
-rw-r--r--   1 keven    user          32 10月  2 07:51 test.txt
-rw-r--r--   1 keven    user           0  9月 30 08:54 test3
-rw-r--r--   1 keven    user           0  9月 30 08:54 test2
-rw-r--r--   1 keven    user           0  9月 30 08:54 test1




用户和权限
chmod
#chmod u+r test.txt
#chmod go+rw test.txt
#chmod o-w test.txt
#chmod 555 test.txt
#chmod +t dir     //粘带位权限
#chmod g+s file.txt  //setuid
#chmod u+s file.txt  //setgid

chown
#chown new_owner filename
#chown -R  new_owner directoryname

chgrp
#chgrp new_group filename
#chgrp -R new_group filename
nice
#nice -20 dtterm    //优先级增加到20   数值越大优先级越高
#nice --20 dtterm    //优先级减少到20

groups
$ groups                //显示自己所在的组
adm
$ groups root           //显示该用户属于什么组
other root bin sys adm uucp mail tty lp nuucp daemon

newgrp
$newgrp adm   //切换到其它的组

umask
% umask
22
起始权限-想得到的权限=umask值

useradd
#useradd user3
#useradd -u 1006 -g 4 -d /export/home/user3 -s /bin/sh  -c “web user” user3   //完整的添加用户
#useradd -u 1006 -g 4 -d /export/home/user3  -m -s /bin/sh  -c “web user” user3  //创建用户的同时创建主目录文件



参数 说明
-c 对每个用户的注释,
分享到:
评论

相关推荐

    Solaris命令手册

    Solaris命令手册,非常全面,是某个公司内部的哦

    Solaris的中文命令参考手册

    Solaris的中文命令参考手册

    Solaris的中文命令

    Solaris的中文命令,这是我自己收藏的,比上一次还全,很有用呀!

    Solaris知识库,Solaris中文FAQ,UNIX常用命令

    Solaris知识库,Solaris中文FAQ,UNIX常用命令

    solaris命令收集

    Solaris 的中文命令参考手册精简版

    Solaris 9 技术大全 中译本(清晰PDG格式)

    全面系统地介绍了Solaris系统的基本概念以及命令的使用,目的是帮助读者迅速掌握Solaris系统的管理和使用。 本书既覆盖了通用的UNIX主题—设备、进程、shell、编程,同时又囊括了Solaris的专有主题—NIS+、卷管理、...

    Solaris 技术指南part4(共5)

    Solaris 技术指南,清晰中文版PDF.适合新手学习和专业人员查看. &lt;br&gt; 本书内容丰富全面,广泛适用于各层次读者。其中第一部分面向初级用户,介绍了大量的Solaris/UNIX基本知识;第二部分则面向中高级用户,介绍了...

    基于Solaris的操作系统实验设计与实现-含程序源代码、论文、实验数据 1、实验脚本、实验命令和实验结果文件夹:内含所有实验的

    基于Solaris的操作系统实验设计与实现-含程序源代码、论文、实验数据 1、实验脚本、实验命令和实验结果文件夹... 翻译:Solaris 动态跟踪指南:前言及概述———是比较完整的翻译,可以做为学习DTrace的中文参考资料。

    Solaris 技术指南part2(共5)

    Solaris 技术指南,清晰中文版PDF.适合新手学习和专业人员查看. &lt;br&gt; 本书内容丰富全面,广泛适用于各层次读者。其中第一部分面向初级用户,介绍了大量的Solaris/UNIX基本知识;第二部分则面向中高级用户,介绍了...

    Solaris 技术指南part3(共5)

    Solaris 技术指南,清晰中文版PDF.适合新手学习和专业人员查看. &lt;br&gt; 本书内容丰富全面,广泛适用于各层次读者。其中第一部分面向初级用户,介绍了大量的Solaris/UNIX基本知识;第二部分则面向中高级用户,介绍了...

    Solaris 技术指南part5(共5)

    Solaris 技术指南,清晰中文版PDF.适合新手学习和专业人员查看. &lt;br&gt; 本书内容丰富全面,广泛适用于各层次读者。其中第一部分面向初级用户,介绍了大量的Solaris/UNIX基本知识;第二部分则面向中高级用户,介绍了...

    Solaris 技术指南part1(共5)

    Solaris 技术指南,清晰中文版PDF.适合新手学习和专业人员查看. &lt;br&gt; 本书内容丰富全面,广泛适用于各层次读者。其中第一部分面向初级用户,介绍了大量的Solaris/UNIX基本知识;第二部分则面向中高级用户,介绍了...

    sun solaris 用户手册

    中文版用户手册,包括常用命令,配置等等。 很实用的

    LINUX命令编辑器与SHELL编程(中文)01

    并且,当需要立即得到答案时,可以翻到本书的命令参考部分,这部分内容经过精心组织和标注,非常易于快速查找! 作者简介 Mark G.Sobell是Sobell Associates 公司的主席,该公司是一个专于UNLX/Linux 培训、技术...

    unix大全(涵盖了UNIX学习的方方面面)

    69.aris9的jumpstart服务器配置中文详解 70.p 2.0.18版本在SOLARIS上的安装过程 71.N内架设简单的时间服务器time server 72.aris 9环境下基于Postfix的反垃圾反病毒邮件服务器构建 73.LARIS8(X86)下安装J2SE 74. ...

    Unix & Linux大学教程 中文版 pdf

    在本书中,不仅可以全面学习到Unix和Linux操作系统的工作原理和主要命令,还可以知晓Unix和Linux发展史上的许多奇闻趣事。 另外,本书还解释了622个Unix专业术语,许多术语都给出了其历史来源;书中的示例涵盖了...

    Sun Studio 11 C++迁移指南

    本书介绍从 4.0、4.0.1、4.1 或 4.2 版的 C++ 编译器中迁移代码而需要了解的事项。...本手册适用于具有 C++ 使用经验并对 Solaris™ 操作环境和 UNIX® 命令有一定了解的编程人员。 (中文PDF版本,带书签)

    MySQL中文参考手册.chm

    MySQL中文参考手册.chm 449kb &lt;br/&gt;0 译者序 1 MySQL的一般的信息 1.1 什么是MySQL? 1.2 关于本手册 1.2.1 本手册中使用的约定 1.3 MySQL的历史 1.4 MySQL的主要特征 1.5...

Global site tag (gtag.js) - Google Analytics