1.发送邮件并带附件

  1. echo "test"|mail -s "itnihaotest" -a /etc/passwd itnihao@qq.com

注意:此命令在mailx-8.1.1(rhel5.X)版本上不能运行,在mailx-12.2(rhel6.X)可以运行

2.加到 /etc/bashrc,将用户的操作命令记录系统日志syslog,添加完毕source /etc/bashrc

  1. PROMPT_COMMAND='{ msg=$(history 1 | { read x y; echo $y; });user=$(whoami); logger $(date "+%Y-%m-%d %H:%M:%S"):$user:$msg:$(who am i); }'

下面的命令也有相同作用

  1. PROMPT_COMMAND='history -a >(tee -a ~/.bash_history | logger -t "$USER[$$] $SSH_CONNECTION")'

3.mysql备份指定字符集

  1. mysqldump -uroot --default-character-set=utf8  -p vw>vw.sql  

4.踢出系统中已经登录的用户

  1. pkill -kill -t pts/0

5.安装dz提示无法连接到/etc/mysql.sock

  1. Can't connect to local MySQL server through socket '/etc/mysql.sock' (2)  

  2. ln -s /tmp/mysql.sock /etc/mysql.sock

6.mysql密码漏洞链接

  1. http://www.sunchangming.com/blog/?p=4260

  2. http://seclists.org/oss-sec/2012/q2/493

  3. http://www.freebuf.com/vuls/3815.html

  4. https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/scanner/mysql/mysql_authbypass_hashdump.rb

7.sudo命令的执行 用来排除不允许执行的命令

  1. root    ALL=(ALL)       ALL admin   ALL=(root)      NOPASSWD: ALL admin   ALL=(root)      NOPASSWD: !/sbin/fdisk,!/sbin/iptables

8.清除dmesg信息

  1. dmesg -c

9查看apache404的资源

  1. awk '$9 ~ 404{print $7}' /usr/local/apache2/logs/access_log|sort -nr|uniq

10硬盘相关测试

  1. hdparm -t /dev/sda              读取速度测试

  2. hdparm  -I /dev/sda|grep Serial 序列号

11清除僵尸进程

  1. `ps -ef | grep '<defunct>'|grep -v grep |awk '{print $2,$3}'|sed "s/^/kill -9

  2. /g"`

12查看tcp连接数

  1. netstat -n|grep ^tcp|awk '{print $NF}'|sort -nr|uniq -c

13. 查找替换文件

  1. find /tmp  -name "*.*" -print|xargs -i sed -i "s/aaa/bbb/g" {}

14.tcpdump抓vlan数据包

  1. tcpdump -n -q -i eth0 vlan and src host 10.10.10.10 and dst host 20.20.20.20 and tcp[20:4]=0x47455420 -XX -s 250  

  2. tcpdump -n -q -i eth2 tcp[20:4]=0x47455420 -XX -s 0

15.ip138查ip地址接口
http://ip138.com/ips1388.asp?

nagios插件

centreon使用中文

http://code.google.com/p/cacti-nagios/downloads/list
16解压rpm包
rpm2cpio httpd-2.2.3-45.el5.x86_64.rpm | cpio -div
17xen  loop设备不够用
Xen虚拟机Linux下的loop设备增加  http://blog.csdn.net/jackxinxu2100/article/details/4957508

18 mysql分页显示
  1. mysql>pager less; 设置分页显示变量

  2. mysql>show processlist\g; 接\g参数

  3. mysql>nopager; 取消分页显示

119查看tcp连接数状态信息

  1. netstat -an|awk '/^tcp/ {++S[$NF]} END {for(a in S) {printf "%11-s %s\n", a,S[a]}}'

20unrar

http://www.rarlab.com/rar/rarlinux-x64-4.2.0.tar.gz

21批量删除海量文件

  1. rsync --delete-before -a -H -v --progress --stats 空文件夹/  目标文件夹/

22给某个终端用户发送消息

  1. #write admin pts/2  #admin用户所在的终端未pts/2

  2. 输入文件内容,对方显示

23linux挂载windows共享

  1. mount -o username=123,password=123 //172.18.0.10/file /mnt/file

24vim取消选择亮色

  1. 不退出VIM时,取消高亮一直生效:set nohlsearch只是取消上次查找内容的高亮,下次查找会再次高亮:nohlsearch

25 ntfs-3g

  1. http://www.tuxera.com/community/ntfs-3g-download/

26  centos5.5  ext4的支持

  1. yum -y install e4fsprogs

27 获取本机ip地址

  1. ip a|awk -F "inet|/"  '/inet.*brd/ {print $2}'

  2. ifconfig |awk -F 'inet addr:|Bcast:'  '/Bcast:/{print $2}'

http://www.iqm.cn

28 改变终端提示符颜色

  1. export PS1='[\[$(tput bold)$(tput setb 4)$(tput setaf 1)\]\u@\h ~ \A \[$(tput bold)$(tput setb 4)$(tput setaf 2)\]\w\[$(tput bold)$(tput setb 4)$(tput setaf 7)\]]\[$(tput bold)$(tput setb 4)$(tput setaf 6)\]\#\$\[$(tput bold)$(tput setb 4)$(tput setaf 7)\]'

29 记录用户操作日志

  1. export PROMPT_COMMAND='{ msg=$(history 1 | { read x y; echo $y; });logger "[hostname- $(hostname)]": "[euid=$(whoami)]":$(who am i):[`pwd`]:"$msg"; }'

30.windows git

http://code.google.com/p/tortoisegit/

https://code.google.com/p/msysgit/

31软件下载地址

resin

http://www.caucho.com/download/download-archive/

http://bgp.he.net

http://www.freelancer.com   国外外赚的一个网站,留着以后看看

32 查看被删除的,但进程在使用中的文件

  1. lsof | awk '$9~/^\// && $7 > 10000000'|grep deleted

http://support.ipmonitor.com/mibs/IANA-LANGUAGE-MIB/item.aspx

33 子网掩码计算工具


  1. http://mirrors.sohu.com/ubuntu/pool/universe/n/netmask/

34 新浪ip地址解析接口

http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip=123.124.2.85

35.rpm官方资料

http://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/index.html



zabbix资料

http://blog.sina.com.cn/s/blog_704836f40101g0fb.html

http://wenku.baidu.com/view/2491ee0a4a7302768e993968.html



35.mysql删除bing-log

PURGE MASTER LOGS TO 'mysql-bin.010';
PURGE MASTER LOGS BEFORE '20013-04-02 22:46:26';
PURGE MASTER LOGS BEFORE DATE_SUB(CURRENT_DATE, INTERVAL 3 DAY);


36 netmask ip地址计算工具

http://mirrors.sohu.com/ubuntu/pool/universe/n/netmask/netmask_2.3.12.tar.gz

37 查找僵尸进程

http://inbank2012.blog.51cto.com/6302802/1094008

38 linux下乱码文件的删除

shell#ls -i     #找出i节点后删除
15899955 ?=x^??????S?E??
shell#find  ./  -inum 15899955  -print  -exec  rm {} -rf \;