free,ps,抓包,網絡狀態

free 查看內存

[root@binbinlinux ~]# free -h
total used free shared buffers cached
Mem: 1.8G 126M 1.7G 244K 8.7M 39M
-/+ buffers/cache: 78M 1.7G
Swap: 2.0G 0B 2.0G
free 也包含內存 free 單位是kb free -m 是以兆爲單位,free -g 以g爲單位
最精準的就是什麼都不加
total 多大內存 used 使用了多少 free剩餘內存 看第二列 1826864
buffers cpu寫入磁盤數據暫時存放buffers (cpu處理速度過快磁盤寫入較慢所以暫時存放buffers) cached (cpu調用磁盤數據較慢 提前調出放入cached )暫時存cached
buffers 剩餘 cached 剩餘
ps查看進程
[root@binbinlinux ~]# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 19232 1520 ? Ss 18:34 0:01 /sbin/init
root 2 0.0 0.0 0 0 ? S 18:34 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S 18:34 0:00 [migration/0]
[root@binbinlinux ~]# ps -elf
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
4 S root 1 0 0 80 0 - 4808 poll_s 18:34 ? 00:00:01 /sbin/init
1 S root 2 0 0 80 0 - 0 kthrea 18:34 ? 00:00:00 [kthreadd]
1 S root 3 2 0 -40 - - 0 migrat 18:34 ? 00:00:00 [migration/0]
1 S root 4 2 0 80 0 - 0 ksofti 18:34 ? 00:00:00 [ksoftirqd/0]
1 S root 5 2 0 -40 - - 0 cpu_st 18:34 ? 00:00:00 [stopper/0]
user 是那個用戶運行了這個進度 pid 是它的一個標誌數 cpu 百分比佔用了多少
%mem 百分比佔用了多少內存 vsz 虛擬內存的大小 rss 真正內存的大小 tty它從哪裏啓動的
stat 用來表示進程的狀態 (S 在休眠s是個主進程或者副進程)(<表示這個進程的優先級較高)
(N表示進程的低優先級的)(S<s 不僅是主進程 還是高優先級的主進程)(+表示在前臺運行的進程)(R正在運行的 )(L表示在內存被鎖了內存翻頁)(l表示一個多線程進程)(Z殭屍進程 )
(X表示已經死掉的進程)(T表示暫停的進程 )(D表示能中斷的進程)
command進程的名字 time 進程佔用cpu的時間
[root@binbinlinux ~]# ps -aux |ing nginx 過濾 nginx
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root 1688 0.0 0.0 103316 872 pts/1 D+ 19:59 0:00 grep --color nginx
[root@binbinlinux ~]# ps -aux |ing php
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root 1690 0.0 0.0 103316 896 pts/1 S+ 19:59 0:00 grep --color php
netstat 查看端口

80, web服務 22 ,sshd 25,sedmail 發郵件的 11211,memcached 一種緩存服務
111 ,同步數據的服務
[root@binbinlinux ~]# netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:111 0.0.0.0: LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:
LISTEN

time wait ,他們之間已經傳輸完了 我們在等待並沒有斷開
established ,已經建立連接了正在通信
netstat -an 看看服務端與客戶端通信
netstat -an |grep 122.112.69.86:80 過濾出80端口 80端口所以通信的網絡狀態
netstat -an |grep 122.112.69.86:80 |grep -ic estab 這臺服務器併發數是884 ,在這一時刻之內 有884個連接 (併發數兩三萬是沒問題的)
抓包工具tcpdump和tshard
yum install -y tcpdump 安裝這個包 tcpdump 抓包
tcpdump -nn -c 100
第一個是時間 第二個是毫秒更精準的時間 第三個是ip 來源的ip 來源的paote 以及目標的ip目標的paote 後面是狀態
有時候你發現你的網卡有點堵塞,跑滿了抓包的時候發現某一個端口到某一個端口的數據包很多而且他們大多都是一樣的,可能是被***了。

[root@binbinlinux ~]# tcpdump -nn -i eth0 抓指定的網卡
[root@binbinlinux ~]# tcpdump -nn port 22 抓22端口的數據包 跟port
[root@binbinlinux ~]# tcpdump -nn tcp and port 22 也可以指定協議 tcp 的
[root@binbinlinux ~]# tcpdump -nn udp 這些都是udp的包
root@binbinlinux ~]# tcpdump -nn tcp and port 80 and host 192.168.1.103
指定ip 指定 port 可以多項指定加and
root@binbinlinux ~]# tcpdump -nn tcp and port 80 and host 192.168.1.103 -w 1.cap
-w 把抓的包記錄到一個文件裏去
[root@binbinlinux ~]# tcpdump -r 1.cap 查看抓包的數據流向
[root@binbinlinux ~]# tcpdump -nn -s0 tcp and port 80 -c 10 -w 2.cap s0抓一個完整的包
tshark
[root@binbinlinux ~]# yum install -y wireshark 安裝這個包
[root@binbinlinux ~]# tshark -nn 和tcpdump -nn 類似
[root@binbinlinux ~]# 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"
http://ask.apelearn.com/question/995 tshark 抓包用法
http://www.doc88.com/p-9913773324388.html 第三次握手

selinux

[root@abinlinux ~]# cat /etc/selinux/config selinux 的配置文件 所在
enforcing 完全打開匹配這個規則就會被阻斷
permissive 開着, 不去限制你 直接記錄下日誌
disabled SELINUX=disabled 直接把它關掉了
[root@abinlinux ~]# setenforce 0 關閉 selinux
setenforce: SELinux is disabled
[root@abinlinux ~]# setenforce 1 打開selinux 必須在enforcing狀態下
setenforce: SELinux is disabled
[root@abinlinux ~]# rpm -qf which setenforce 查詢selinux
libselinux-utils-2.0.94-5.8.el6.x86_64

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章