ps aux|grep httpd|grep -v grep|awk '{print $2}'|xargs kill -9 查杀所有httpd进程
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg –dmount -t cifs //172.172.172.250/temp /mnt -o username=chenwu 挂在本地共享
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg -d 测试nagios
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg 启动nagios
cat /proc/cpuinfo |grep "physical id"| sort | uniq | wc -l
cat /proc/cpuinfo |grep "cpu cores"| uniq
cat /proc/cpuinfo |grep "model name" | uniq
cat /proc/cpuinfo |grep "processor" | wc -l
查找当前目录下所有包含 8080字符的文件
find .|xargs grep -ri "8080"
利用 9002替换8080;当前目录下所有文件的8080.
sed -i "s/8080/9002/g" `find .|xargs grep -rl "8080"`
物理cpu个数
每个cpu的核数
查看cpu型号
查看逻辑cpu的个数
du -cks *|sort -rn|head -n 20 排序文件或目录大小
cat /var/log/messages | sed -n '/19:40:00/,/20:20:00/p' 查看自定义时间段日志
file /sbin/init
grep -Ev '(^$)|(^\s*#)' /etc/vsftpd/vsftpd.conf | wc -l 只显示vsftpd.conf文件的有效行 wc -l 统计输出行数
cat -n /etc/passwd 行数显示每行
find . -name *.c |xargs wc -l
find . -name *.cpp | xargs wc -l
find . -name *.h |xargs wc -l
find /etc/ -type f | wc -l #统计/etc/下文件的个数
find /etc/ -type f -name "*iscsi*" | wc -l #统计文件名中带有iscsi的文件数
find /etc/ -type f -exec grep "mdadm" {} \; | wc -l #统计/etc/目录下,带有mdadm内容的行数
find /etc/ -type f -name "*iscsi*" | awk 'END{print NR}' #统计文件名中带有iscsi的文件数
find /etc/ -type f -exec grep "mdadm" {} \; | awk 'END{print NR}' #统计/etc目录下,带有mdadm内容的行数
添加路由:
route add -net 10.0.0.0 netmask 255.0.0.0 dev eth0
删除路由:
route del -net 10.0.0.0 netmask 255.0.0.0 dev eth0
添加默认路由:
route add default gw 10.0.0.1
删除默认路由:
route del default gw 10.0.0.1
modprobe bonding miimon=100 mode=1 mode=可能的值为0(默认的轮转模式round robin policy),或者1(热备份模式),miimon=整数值,定义MII链路监测频率(单位为频率)。默认值为0,表示关闭链路监测。如果希望使用链路监测,一个合适的值为100
useradd trend
pwconv
passwd trend
trend!123
pwunconv
visudo
trend ALL=(ALL) /etc/init.d/splx
[root@ sand ~]$ cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
1 Intel(R) Core(TM) i3 CPU M 370 @ 2.40GHz
[root@ sand ~]$getconf LONG_BIT Linux查看版本说明当前CPU运行在32bit模式下, 但不代表CPU不支持64bit
32
[root@ oracle ~]$getconf LONG_BIT
64
[root@ sand ~]$ cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l 结果大于0, 说明支持64bit计算. lm指long mode, 支持lm则是64bit
1
scp -P 999 root@21andy.com:/home/test.zip /home/ 复制远程服务器的文件到本地
scp -P 999 -r /home/andy/ root@21andy.com:/home/ 复制本地的目录到远程服务器
跟踪系统进程,解决故障
strace -o strace.splunk.out ./splunk start
1031 ./splunk stop
1032 ./splunk status
1033 ltrace -o ltrace.splunk.out ./splunk start
1034 cat ltrace.splunk.out
1035 more ltrace.splunk.out
1036 unset LD_LIBRARY_PATH
1037 echo $LD_LIBRARY_PATH
1038 ./splunk start
1039 ./splunk stop
1040 env
1041 strace ./splunk start
删除大批量小文件 以此类推,应该可以将rm改为cp一次copy大数目的文件。
1.find
find . -name * -exec rm {}\;
2.管道
ls -l |awk '{print $9}'|rm
如果要删除目录,则在rm命令里用r参数,如果删除时不需要提示,就加上f参数,rm的r和f参数要慎用!
\cp abc.txt /home
直接复制abc.txt 到/home 里面,不管/home 里面之前是否有这个文件都会直接覆盖,不再出现覆盖提示!
#!/bin/bash
auto_smart_ssh () {
expect -c "set timeout -1;
spawn ssh -o StrictHostKeyChecking=no $2 ${@:3};
expect {
*assword:* {send -- $1\r;
expect {
*denied* {exit 2;}
eof
}
}
eof {exit 1;}
}
"
return $?
}
scp自动交互口令
auto_smart_ssh passwd user@host ls /var
echo -e "\n---Exit Status: $?"
auto_scp () {
expect -c "set timeout -1;
spawn scp -o StrictHostKeyChecking=no ${@:2};
expect {
*assword:* {send -- $1\r;
expect {
*denied* {exit 1;}
eof
}
}
eof {exit 1;}
}
"
return $?
}
auto_scp pass ~/myfile user@host:~/path/to/myfile
echo $?
find / -name access_log 2>/dev/null
find /etc -name ‘*srm*’
find / -amin -10 # 查找在系统中最后10分钟访问的文件
find / -atime -2 # 查找在系统中最后48小时访问的文件
find / -mmin -5 # 查找在系统中最后5分钟里修改过的文件
find / -mtime -1 #查找在系统中最后24小时里修改过的文件
find / -cmin -5 # 查找在系统中最后5分钟里被改变状态的文件
find / -ctime -1 #查找在系统中最后24小时里被改变状态的文件
find / -user reda #查找在系统中属于fred这个用户的文件
find / -not -user reda #查找在系统中不属于FRED这个用户的文件
find / -group redagrp # 查找在系统中属于redagrp组的文件
find / -gid 501 #查找系统中属于组id为501的文件
find / -user fred -a -group redagrp
find / -user reda -o -user tracy
find / -nouser #查找在系统中属于作废用户的文件
find / -empty # 查找在系统中为空的文件或者为空的文件夹
find / -false #查找系统中总是错误的文件
find / -size +5k #查找系统中大于5k字节的文件
find / -size +5c #查找系统中大于5字节的文件
find / -perm +6000
find / -type b
文件类型:
b 块(缓冲)设备.
c 字符设备.
d 目录.
p 有名管道(FIFO).
f 规则文件.
l 符号链结.
s SOCKET.
find / -maxdepth 2 -name fred
find /tmp -size +10000000c -and -mtime +2
find / -user reda -or -user tracy
find /tmp ! -user reda
find / -name "httpd.conf" -ls
find / -user reda -exec ls -l {} \;
find / -user reda -ok #确认后执行
find / -user reda | xargs ls -l