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


本文转自 amenging 51CTO博客,原文链接:http://blog.51cto.com/11335852/2045503


相关文章
|
14天前
|
存储 缓存 监控
深入解析linux内存指标:快速定位系统内存问题的有效技巧与实用方法(free、top、ps、vmstat、cachestat、cachetop、sar、swap、动态内存、cgroops、oom)
深入解析linux内存指标:快速定位系统内存问题的有效技巧与实用方法(free、top、ps、vmstat、cachestat、cachetop、sar、swap、动态内存、cgroops、oom)
|
机器学习/深度学习 网络协议 Unix
|
26天前
|
存储 监控 Linux
【Shell 命令集合 系统管理 】⭐⭐⭐Linux 查看当前正在运行的进程信息 ps命令 使用指南
【Shell 命令集合 系统管理 】⭐⭐⭐Linux 查看当前正在运行的进程信息 ps命令 使用指南
40 0
|
2月前
|
Linux
百度搜索:蓝易云【Linux系统ps命令:查看正在运行的进程】
通过这些简洁的ps命令用法,你可以方便地查看Linux系统中正在运行的进程信息。
33 1

热门文章

最新文章