寻觅生命中的那一片浅草......

文章带标签 Linux

install vim7.2 on debian

wget ftp://ftp.vim.org/pub/vim/unix/vim-7.2.tar.bz2

sudo apt-get install libncurses5-dev

tar xf vim-7.2.tar.bz2

cd vim72

sudo ./configure –with-features=huge –enable-cscope –enable-multibyte

sudo make

sudo make install

enable syntax :

/bin/cp runtime/gvimrc_example.vim ~/.vimrc

tcpdump详细用法

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://dgfpeak.blog.51cto.com/195468/277304
常用参数简介:
-i指定监听网卡,用于机器有多个网卡的情况
-c指定要监听的数据包的数量
-w将监听到的数据包存入文件中

I.定义类型的参数
包括host,net,port,分别对应着主机,网络地址和端口

II.定义传输方向的参数
包括src,dst,dst or src,dst and src

III.定义协议的参数
包括fddi,ip,arp,tcp,udp等

IV.除以上之外还有gateway,broadcast,less,greater
逻辑运算符:1)非 not ! 2)与 and && 3)或 or ||

1> #tcpdump 直接启动tcpdump默认监听第一块网卡上面流过的所有数据包
2> #tcpdump host 222.222.222.222 获取该主机上面收到和发出的所有数据包
3> #tcpdump host A and \(B or C\) 获取主机A和B或C的通信信息,注意括号
4> #tcpdump ip host A and !B 获取A和除了B的所有ip包
5> #tcpdump tcp port 23 host A 获取A发出或接受的所有telnet包
6> #tcpdump udp port 123 监听udp123端口的ntp服务
7> #tcpdump -i eth0 src host hostname 监听来自hostname的所有信息
8> #tcpdump -i eth0 gateway gatewayname 监听通过网关的数据包
9> #tcpdump -i eth0 host hostname and (src or dst)port 80 监听指定端口的信息

当网卡开启混杂模式时,系统日志里会有如下信息
March 9 10:03:06 localhost kernel: eth0: Promiscuous mode enabled.
March 9 10:03:06 localhost kernel: device eth0 entered promiscuous mode
March 9 10:03:07 localhost kernel: device eth0 left promiscuous mode

tcpdump对截获的数据并没有进行彻底解码,数据包内的大部分内容是使用十六进制的形式直接打印输出的。显然这不利于分析网络故障,通常的解决办法是 先使用带-w参数的tcpdump 截获数据并保存到文件中,然后再使用其他程序进行解码分析。当然也应该定义过滤规则,以避免捕获的数据包填满整个硬盘。

除了过滤语句,还有一个很重要的参数,也就是说,如果这个参数不设置正确,会导致包数据的丢失!它就是-s 参数,是数据包的截取长度,仔细看man就会明白的!默认截取长度为60个字节,但一般ethernet MTU都是1500字节。所以,要抓取大于60字节的包时,使用默认参数就会导致包数据丢失!

只要使用-s 0就可以按包长,截取数据

本文出自 “Get and Share” 博客,请务必保留此出处http://dgfpeak.blog.51cto.com/195468/277304

Vim 杀手级 Tip: 快速处理配对标点符号中的文本

这称得上是一个 Vim 的杀手级 Tip,利用该 Tip,你可以快速处理 ‘、”、()、[]、{}、<> 等配对标点符号中的文本内容,包括更改、删除、复制等。
ci’、ci”、ci(、ci[、ci{、ci< – 分别更改这些配对标点符号中的文本内容
di’、di”、di(、di[、di{、di< – 分别删除这些配对标点符号中的文本内容
yi’、yi”、yi(、yi[、yi{、yi< – 分别复制这些配对标点符号中的文本内容

对于经常用 Vim 写代码的朋友来说,善用此 Tip 将极大的提高编码效率。

转载自:http://linuxtoy.org/archives/killer-vim-tip.html

使用mod_rewrite时要当心MultiViews

使用mod_rewrite时要当心MultiViews

先看我遇到的问题:试图使用如下rewrite代码

RewriteEngine On

RewriteBase /dex/

RewriteRule ^wsdl/(sjz|bd|qhd|common)/?$ wsdl.php?u=$1 [L]

RewriteRule ^wsdl/?$ wsdl.php [L]

达到以下转换效果:

wsdl/sjz –> wsdl.php?u=sjz

wsdl/ –> wsdl.php

但天不随人愿,第二行转换效果没问题,第一行转换效果总是出不来,查了一下RewriteLog,有一句引起了我的注意:

(1) pass through /dex/wsdl/sjz

(3) [per-dir E:/cvswork/2005dex/] add path info postfix: E:/cvswork/2005dex/wsdl.php -> E:/cvswork/2005dex/wsdl.php/sjz

注意看第二句,它怎么把wsdl/sjz转换成了wsdl.php/sjz?难道和第二句RewriteRule有关?试着把第二句RewriteRule关掉,问题依旧。

于是祭起Google海搜,发现有人和我遇到了同样的问题:

the problem lies in here somewhere

with URL http://localhost/index/q we get:-

add path-info postfix: c:/wwwroot/index.php -> c:/wwwroot/index.php/q

strip per-dir prefix: c:/wwwroot/index.php/q -> index.php/q

applying pattern ‘^([^/.]*)$’ to uri ‘index.php/q’

I dont want index.php/q though!!!!! argghhhhh!!!

……

GOT IT!!!!!!!

Bl**dy windows OS

i removed the .htaccess file and http://localhost/phpinfo/x was still doing phpinfo.php

I added a directory called phpinfo and it worked – giving a directory listing

I re-created the .htaccess and voila it worked.

So basically if a directory doesnt exist it looks for a script (.php .html) and then uses that with further parameters sdded to the end of it.

I have to find a workaround for that now.

原来,是Apache在当前目录下找到了wsdl.php(依据wsdl/sjz中的wsdl),并且来了个狸猫换太子,继续搜索……终于在这个德语网页找到了答案:

MultiViews-option abschalten.

wenn diese aktiviert ist, würde ein request nach /kategorie auch kategorie.php finden, und das kollidiert natürlich mit deiner RewriteRule, weil dort eben mit /kategorie/irgendwas ebenfalls ein “treffer” vorliegt – da kann der server also nicht entscheiden, was jetzt eigentlich gemeint ist.

上面是德语,我是看不懂的,用Google翻译如下:

MultiViews option switch off.

if this is activated, after/category kategorie.php to also find request, and collides naturally with your RewriteRule, because evenly with/category/something is likewise present there a “hit” – there the server cannot decide thus, what is now actually meant.

原来是Apache的MultiViews选项干扰了RewriteRule,将其去掉之后,问题排除。

Options -MultiViews

继续寻找MultiViews的相关信息,收获如下:

* Beware of Apache’s Multiviews

* 内容协商(Apache手册中文版mod_negotiation部分)

所以,在没有明确需要的情况下,一般不要打开MultiViews选项,因为我们一般编写的程序很少用到它,反而会给正常的程序调试带来麻烦,另外早期的版本可能还存在一些安全问题。

在去掉MultiViews的同时,发现还有一个好像也没有用的Options——FollowSymLinks,但如果你的 RewriteRule是写在.htaccess文件中的话,FollowSymLinks这个选项可不能去掉,去掉了RewriteEngine就不干活啦~~

转载自:http://doc.linuxpk.com/4941.html

如何找出当前占用磁盘IO最多的进程

linux系统上可以使用(centos 2.6.18-144开始支持),dstat版本至少是:dstat-0.6.7-1.rf.noarch.rpm

安装

wget -c http://linux.web.psi.ch/dist/scientific/5/gfa/all/dstat-0.6.7-1.rf.noarch.rpm

rpm -Uvh dstat-0.6.7-1.rf.noarch.rpm

使用

# dstat -M topio -d -M topbio

—-most-expensive—- -dsk/total- —-most-expensive—-

i/o process      | read  writ|  block i/o process

owl_agent  9642B: 439B|  38k   42k|init       8317B:  41B

nginx         0 :2005B|   0    26k|

gmond         0 :  16k|   0    17k|

gmond         0 : 444B|   0     0 |

其他

低于这个kernel版本的可以参考这个方法:http://www.xaprb.com/blog/2009/08/23/how-to-find-per-process-io-statistics-on-linux/

最后多谢光哥和W总~

转载自:http://www.ourlinux.net/operating-system/how-to-find-per-process-io-statistics-on-linux-2/

2025年五月
« 5月    
 1234
567891011
12131415161718
19202122232425
262728293031