linux命令
时间:2006-08-14 来源:huanghaojie
1. find ~/ -name '*.txt'
2. 显示端口 lsof -i -n or netstat -lnp
3. head -2 a.txt 显示a.txt的前两行。
4. echo `comdmand` 将删除任何有command产生的换行符。
5. read var < a.txt 把a.txt的第一行赋给var。
6. ps ax|awk '/ppp/{print $1}' 匹配ppp。
7. find ./ -name file -exec cat {}\; 找出file文件,并显示出内容。
8. find . -name file |xargs cat file 功能同上
7 and 8 difference ,7的exec如何匹配很多,可能会溢出,这时需要用xargs.
9. proc 虚拟系统 echo 1 >/proc/sys/net/ipv4/ip_forward,但重启后以变为0,
这时需要修改/etc/sysctl.conf
10. cat /dev/null >./.bash.history 清空.bash.history的内容 。
11. tcpdump -s600 -i eth1
12. diff -y --suppress-common-line file1 file2 将两个文件不同的行分别显示在左右两测。
13. nmap -A -T4 www.plukkr.com 可以扫描打开的端口
14 nmap 192.168.1.0-254 可以扫描所有机器打开的端口。
15. ifconfig eth0 down
ifconfig eth0 hw ether 00 11 22 33 44 55
ifconfig eth0 up 修改MAC
16. ip link set eth0 address 00:48:54:11:22:33 ##
link set -- change device attributes17. tcpdump dst net not 192.168.123.0/24 不监视跟网内机子的链接,过滤很多信息
不想看发邮件的情况,一般的80网页访问,domain访问,还有要排除网内已有服务器的一些端口。
tcpdump dst net not 192.168.123.0/24 and dst port not ( www or 25 or
110 or 5000 or domain ) and src port ! ( 4011 or 4010 or 4009 )
dst net not 192.168.123.0/24 不监视与网内机器的连接
dst port not ( www or 25 or 110 or 5000 or domain ) 过滤与internet中运行 目标端口的连接,不显示访问网页,邮件,查询DNS的这些连接
src port ! ( 4011 or 4010 or 4009 ) 这个主要是因为 装有虚拟局域网软件,网内服务器与外面分部的连接,不需要显示。 当然这里的端口可以根据实际情况换掉
18. lsof -a -p $$ -d0 ??
19. vi -c ":%s/bin/ssss/g" -c ":wq" file
20. 操作符可以在文件尾添加内容. 如果你想在文件头添加内容,那应该怎么办? 用cat -
# echo "***this is the tetle line of data text fiel"|cat - hello>>hello.1
相关阅读 更多 +