随笔-159  评论-114  文章-7  trackbacks-0

补充两点

echo 反显命令
可以用来创建文件

echo aaa>a.txt
echo bbb>>a.txt追加

users 查看在线用户
比who看到的信息少,但是同时刻用户数一样

统计当前在线用户数

openlab.tarena.ca% users
xiaoyao lujl xiaoyao tanjh
openlab.tarena.ca% users|wc -w
       4

等价于

openlab.tarena.ca% who|wc -l
       4

===========================================================

find / -name file
find . -mtime 10 -print 修改时间距现在正好10天
find /etc -user 0 -size +400 -print /etc目录下 user为0,也就是root为owner的文件,并大小大于400的文件
      注意两个条件为与关系,并且大于400,是data block。

      1data block = 512bytes   也就是 400 data block = 200K

find ~ -perm 777 > ~/holes
      权限为777的
find /export/home -type f atime +365 -exec rm {} \;

      注意后面,-exec空格rm空格{}空格\;  一个都不能少,才可执行删除,删除目录-exec rm -r {} \;

可以用于删除文件名为rm某参数的不可删除文件

例如
      echo aaa>-i 为形成-i的文件

      openlab.tarena.ca% rm -i
      usage: rm [-fiRr] file ...

那么就需要这样来删除
      find . -name '-i' -exec rm {} \;

grep -i  不区分大小写
grep -v 过滤不匹配后面的串

ls -l|grep ^d
      那么就是列出该目录中的子目录

ls -l|grep -v ^d
      列出文件了,因为是-v
与li -l|grep ^-等价

grep file *
到每个文件中寻找"file"串
         
more file*
可以同时查看多个file1,file2,file3。。。的内容。

diff file1 file2

openlab.tarena.ca% echo aaa>file1
openlab.tarena.ca% echo bbb>file2
openlab.tarena.ca% diff file1 file2
1c1
< aaa
---
> bbb

提示说明,将第一个文件的第一行修改成为bbb

openlab.tarena.ca% more file*
::::::::::::::
file1
::::::::::::::
aaa
ccc
::::::::::::::
file2
::::::::::::::
bbb
openlab.tarena.ca% diff file1 file2
1,2c1
< aaa
< ccc
---
> bbb

提示,第一、二两行都变成bbb



openlab.tarena.ca% more file*
::::::::::::::
file1
::::::::::::::
aaa
ccc
::::::::::::::
file2
::::::::::::::
aaa
ccc
zzz
openlab.tarena.ca% diff file1 file2
2a3
> zzz

在第一个文件的第二行后,加入第二个文件的第三行的内容

openlab.tarena.ca% more file*
::::::::::::::
file1
::::::::::::::
aaa
ccc
::::::::::::::
file2
::::::::::::::
aaa
ccc


zzz
openlab.tarena.ca% diff file1 file2
2a3,5
>
>
> zzz

第一个文件第二行,加入第二个文件中的3到5行内容。

openlab.tarena.ca% diff file1 file2
6d5
< xxx

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

openlab.tarena.ca% more file1 file2
::::::::::::::
file1
::::::::::::::
aaa
ccc

zzz

xxx
::::::::::::::
file2
::::::::::::::
aaa
ccc

zzz
openlab.tarena.ca% diff file1 file2
5,6d4
<
< xxx

注意是将第一个文件的5到6行删除,到第二个文件的第四行。


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

ps -ef

e所有进程 f详细列表方式

PID 进程号
PPID 父进程号

任何进程最后都能追踪到inetd

sh -> csh -> in.telnetd -> inet -> init(1) -> sched(0)

ps -ef|grep inetd|grep -v grep|wc -l



ps -ef|more 有各列表头

STIME进程开始时间

TTY 终端 Console
?表示与终端脱离关系的进程,应该是daemon

TIME 累计占用时间

CMD进程名称


/usr/ucb/ps -auwx|more

ps的另外一个实现版本



进程有几种状态,运行,就绪,挂起,僵尸进程。

<default>,由于父进程出现问题,当子进程已经没有了,告诉父,但是父没有消除它,这样造成任在进程表中保留一项,累计多后,对系统造成影响。

上述情况,由程序员造成。解决,杀死父进程。

kill -9 12487

-9表示无条件杀死

pkill sleep
      不需要进程号

-------------------------------------
sleep 100 前台运行,不释放终端控制
sleep 100& 后台运行

jobs -l 列任务

bg 任务号
fg 任务号


stop 进程号 挂起后台进程
Control -z挂起前台进程。
Control -c放弃前台进程。


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

ls file*|xargs grep file

分解输入

grep file file1 file2

查内容了,不等同于ls file*|grep file,将结果给grep,而是分解file*为file1 file2再给grep

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

/etc/hosts
ip与主机名的对应表
/etc/netmasks
/etc/defaultrouter
默认网关
/etc/hostname.hme0
主机名称

/etc/resolv.conf
DNS

/etc/nodename
网卡对应的名称,一台机器有可能有多个网卡,而主机名只有一个,与/etc/hostname.hme0不同。


ping 127.0.0.1(loop back地址),是检查逻辑地址有效否?也就是检查TCP/IP是否安装好?

netstat -rn 查看硬件

rusers -l tarenalab3
远程看lab3上的在线用户。

traceroute www.sina.com.cn

finger user1@tarenalab1



telnet

rlogin hostname -l lujl

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

ftp hostname

lcd 显示本地目录,和设置本地目录

hash 打#每1024

prompt交互信息开关

mget mput

mdelete

rename  可以移动文件!!!!!!!

wall 广播 Ctrl + D

write

talk

mesg -y|-n



posted on 2005-11-16 22:47 北国狼人的BloG 阅读(314) 评论(0)  编辑  收藏 所属分类: 达内学习总结

只有注册用户登录后才能发表评论。


网站导航: