查看系统负载命令

w

cat /proc/cpuinfo
uptime

vmstat 详解

vmstat 1 5

 top 动态查看负载

ls /proc/

top -bn1

top -d 1 一秒显示一次

sar命令

sar -n DEV 1 10

 没有  就安装 yum -y install sysstat

1byt=8bit

ls /var/log/sa/
A sar -q 能够查看系统历史负载

 sar -b 1 10 可以查看当前的磁盘io状态

 sar -n DEV 1 10 可以查看网卡流量

 sar -p 1 10 可以查看cpu的使用情况

 free 查看内存

 free -g 

ps查看进程

ps -aux    -elf   

netstat 查看端口

 netstat -lnp

netstat -an |grep 192.168.1.229:80 |grep -ic estab

抓包工具 tcpdump tshark


yum install tcpdump


tcpdump -nn -c 100

tcpdump -nn -s0 tcp (and) prot 80 and udp and host -c 10 -w 1.cap

man tcpdump

tcpdump -r 1.cap

yum install -y wireshark

tshark -nn

tshark -n -t a -R http.request -T fields -e "frame.time" -e "ip.src" -e "http.host" -e

"http.request.method" -e "http.request.uri"

 




 selinux 介绍 防火墙

cat /etc/selinux/config

  getenforce
setenforce 0

rpm -qf 'which setenfore'

 永久关闭selinux的方法是编辑配置文件/etc/selinux/config, 把SELINUX=Enforceing 改成 SELINUX=Disabled

iptables

netfilter 防火墙 

iptables -t filter -nvL

 iptables -t nat -nvL
 iptables -t mangle -nvL

iptables -t filter -I INPUT -p tcp --dport 80 -s 12.12.12.12 -j REJECT

iptables -t filter -D INPUT -p tcp --dport 80 -s 12.12.12.12 -j REJECT

iptables -A INPUT -p tcp --dport 80 -s 192.168.1.101 -j DROP

 iptables 详解2

 iptables -t filter -I INPUT -p tcp --dport 80 -s 12.12.12.12 -j ACCEPT

iptables -z

iptables -F 清空所有规则

iptables -t filter -I INPUT -p tcp -s 114.255.24.24 -j ACCEPT

service iptables save

iptables-save > 1.ipt

                   <  1.ipt

iptables 详解-3

iptables -t mangle -nvL

表主要用来限制进入本机的包和出去的包

 nat表主要用于网络地址转换,比如家用的小路由器就是用nat表实现的

 mangle表主要用来给包打标记

INPUT DROP ; 192.168.1.10/24 22 accept ; all 80 accept;all 21 accept;

vim 1.apt.sh

!/bin/bash

ipt="sbin/iptables"

$ipt -F

$ipt -P INPUT DRCP  (accept)

           PUTPUT ACCEPT

           FPRWARD ACCEFT

$ipt -A INPUT -S 192.168.0.0/24 IP TCP --DPORT 22 -J ACCEPT

                      -p  tcp --dport 80 -j accept

                      -p   tcp --dport 21 - accept

cron 计划 任务

crontab -l
crontab -e

系统服务

ntsysv

yum install -y ntsysv

 chkconfig --list

chkonfig atd off

chkonfig --list atd

 chkonfig rpcbind off

 chkonfig --level 3 atd on

chkconfig --level 345 atd on

 chkonifg -- add 123

 linux 日志

ls /var/log/messages

 cat /etc/logrotate.conf
kill -HUP

killall httpd

killall -9

tail /var/log/messages

ls /var/log/wtmp

last

ls/var/log/btmp

lsastb

ls /var/log/dmesg 查看硬件、内核相关的日志

dmesg

 2.7 xargs和exec详解

 find /var/log/ -type f -mtime +10
 find /var/log/ -type f -mtime +10 -exec cp {} {}.bak \;

  find /var/log/ -type f -mtime +10 |xargs -i cp {} {}.1

 ls /var/log/spooler-20150921* 

ls |xargs

 screen命令

screen  Ctrl+a D

ps aux |grep -E 'top|vmst'

scren ls

scren -r 1630

screen -ls

screen -S test1

 curl 命令

curl -I baidu.com

vim /etc/hosts

curl  -x13.17.42.40:80 www.qq.com
curl -Iv www.baidu.com
curl -O http://www.baidu.com/img/bdlogo.png

ls bdlogo.png

curl -o baidu.png  http://www.baidu.com/img/bdlogo.png

 ls baidu.png

wget http://www.baidu.com/img/bdlogo.png

rsync格式

rsync -av 192.168.11.199: :aminglinux/123/1.txt /tmp

 rsync -av /tmp/1.txt 192.168.1.199: :aminglinux/123/ v可视化

 rsync -a /tmp/1.txt 1.1.1.1:/tmp/  (a=rlgD)

 rsync -a 1.1.1.1:/tmp/1.txt /tmp/

 rsync -a /tmp/123/ test@1.1.1.1::test/

 rsync -a 2.2.2.2::test/123/ /tmp/123/

rsync常用选项

rsync -u 如果目标文件比源文件还新,那么则忽略该文件

         -L  可以在同步的时候把软链接对应的源文件同步

rsync 选项详解

rsync -av 111/ /tmp/322/

tree 111/

tree /tmp/322/

ln -s /etc/inittab  111/12.txt

rsync -av 111/ /tmp/322/

diff /etc/inittab /tmp/322/12.txt

vim /tmp/322/12.txt

rsync -avL --delete 111/ /tmp/322/

vim /tmp/322/234/aminglinux

rsync -avLu 111/ /tmp/322/

rm -rf /tmp/322/*

rsync -avLu --exclude="23" 111/ /tmp/322/

touch 111/23

rsync -avLuPz 111/ /tmp/322/

 rsync同步之ssh隧道方式

rsyne -avPz 111/ 192.168.11.190:/tmp/111/   推

 rsyne -avPz 111/ 192.168.11.190:/tmp/111/ ./111/  拉

 netatst -lnp

 rsyne -avPz -e "ssh -p 10022"  192.168.11.190:/tmp/111/ ./111/

 iptables -I INPUT tcp  --dport 22 -s 192.168.11.16 -j DROP

iptables -nvL

rsync后台服务方式-1

vim /etc/rsyncd.conf

port=8730

log file=/var/log/rsync.log

pid file=/var/raync.pid

[aming]

path=/tmp/raync

use chroot =true 限定家目录

max connections=4

read only=yes

list=yes

uid=root

gid=root

auth users=aming

secrets file=/etc/rs/passwd

hosts allow=192.168.11.190

[aming1]

path=/tmp/raync

use chroot =true 限定家目录

max connections=4

read only=yes

list=yes

uid=root

gid=root

:WQ

rsync --daemon

pa aux |grep rsyne

cat /var/log/rsync.log

mkdir /tmp/rsync

在192.168.11.190上操作

raync -avzp 192.168.11.16: :aming/1.txt ./

telnet 192.168.11.16

raync -avzp --port 8730 192.168.11.16: :aming

16上  vim/etc/rsumcd.conf

aming:123aaa

3.5 rsync后台服务方式-2