linux系统管理技巧-日常基础命令一
W命令
查看当前系统的负载
[root@localhost ~]# w
11:31:02 up 1 day, 11:01, 2 users, load average: 0.01, 0.03, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root tty1 三00 32:13m 0.22s 0.22s -bash
root pts/1 192.168.1.150 11:27 6.00s 0.52s 0.31s w
[root@localhost ~]#
第一行从左至右显示的信息依次为:时间,系统运行时间,登录用户数,平均负载。
较为重要的是 load average 后面的3个值。
第一个数值表示1分钟内系统的平均负载值,第二个数值表示5分钟内系统的平均负载值,第三个数值表示15分钟内系统的平均负载值。
着重看第一个值,值越大,服务器压力越大,一般情况下,这个值不要超过服务器的cpu数量就没有关系。
查看CPU
[root@localhost ~]# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 61
model name : Intel(R) Core(TM) i5-5200U CPU @ 2.20GHz
stepping : 4
microcode : 0x1f
cpu MHz : 2196.850
....................................................
/proc/cpuinfo 文件记录了CPU的详细信息
[root@localhost ~]# grep -c 'processor' /proc/cpuinfo
1
[root@localhost ~]#
可直接使用grep过滤查看当前服务器有几个cpu
查看物理CPU需要查看关键字 physical id
VMSTAT命令
监控系统状态
[root@localhost ~]# vmstat
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
2 0 0 469444 2156 429924 0 0 2 4 50 48 0 0 100 0 0
[root@localhost ~]#
procs显示进程的相关信息
r(run):表示运行或者等待cpu时间片的进程数,某一时刻1个cpu只能有一个进程占用,其他进程只能排队等候,此时这些排队等待cpu资源进程依然是运行状态。
b(block):表示资源的进程数,指的是 I/O 、内存等。
memory显示内存的相关信息
swpd:表示切换到交换分区中的内存输了,单位为 KB 。
free:表示当前空闲的内存数量,单位为 KB 。
buff:表示即将写入磁盘的缓存大小,单位为 KB 。
cache:表示从磁盘读取的缓存大小,单位为 KB 。
swap显示内存的交换情况
si:表示从交换分区写入内存的数据量,单位为 KB 。
so:表示从内存写入交换分区的数据量,单位为 KB。
io显示磁盘的使用情况
bi:表示从块设备读取数据的量----读磁盘,单位为 KB。
bo:表示从块设备写入数据的量----写磁盘,单位为 KB。
system显示采集间隔内发生的中断次数
in:表示在某一时间间隔内观测到的每秒设备的中断次数。
cs:表示每秒产生的上下文切换次数。
cpu显示CPU的使用状态。
us:显示用户下所花费CPU的时间百分比
sy:显示系统花费的CPU时间百分比
id:表示CPU处于空闲状态的时间百分比
wa:表示 I/o 等待所占用的时间百分比
st:表示被偷走的CPU所占百分比
每隔一秒输出一次状态,输出五次
[root@localhost ~]# vmstat 1 5
procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu-----
r b swpd free buff cache si so bi bo in cs us sy id wa st
2 0 0 469552 2156 430104 0 0 2 4 50 48 0 0 100 0 0
0 0 0 469536 2156 430104 0 0 0 0 71 68 0 1 99 0 0
1 0 0 469536 2156 430104 0 0 0 0 55 52 0 0 100 0 0
0 0 0 469536 2156 430104 0 0 0 1 68 69 0 1 99 0 0
0 0 0 469536 2156 430104 0 0 0 0 56 52 0 1 99 0 0
[root@localhost ~]#
vmstat 1 表示每隔一秒输出一次状态,并且一直输出,直到你按 CTRL + C 键 结束
TOP命令
动态监控进程所占的系统资源
top - 12:18:14 up 1 day, 11:48, 2 users, load average: 0.00, 0.01, 0.05
Tasks: 87 total, 1 running, 86 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.7 sy, 0.0 ni, 99.0 id, 0.0 wa, 0.0 hi, 0.3 si, 0.0 st
KiB Mem : 1008152 total, 468612 free, 106776 used, 432764 buff/cache
KiB Swap: 2097148 total, 2097148 free, 0 used. 712560 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2979 root 20 0 0 0 0 S 0.3 0.0 0:12.72 kworker/u128:2
5513 root 20 0 0 0 0 S 0.3 0.0 0:11.77 kworker/0:3
5524 root 20 0 145700 5200 3924 S 0.3 0.5 0:02.10 sshd
1 root 20 0 128164 6828 4060 S 0.0 0.7 0:32.78 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.21 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:10.44 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
动态监控进程所占资源,3秒变一次。
把占用系统资源(CPU,内存,磁盘 I/O 等)最高的进程放在最前面。
RES表示进程所占内存大小,%MEM为使用内存的百分比。
在TOP状态下,按shift+m键可以按照内存使用大小排序,按数字1可以列出所有核CPU的使用状态,按q可退出top
top-bn1
[root@localhost ~]# top -bn1 | head
top - 12:28:27 up 1 day, 11:59, 2 users, load average: 0.17, 0.06, 0.06
Tasks: 87 total, 2 running, 85 sleeping, 0 stopped, 0 zombie
%Cpu(s): 6.2 us, 12.5 sy, 0.0 ni, 81.2 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1008152 total, 468320 free, 107012 used, 432820 buff/cache
KiB Swap: 2097148 total, 2097148 free, 0 used. 712320 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5650 root 20 0 108128 664 564 S 11.1 0.1 0:00.11 head
3 root 20 0 0 0 0 S 5.6 0.0 0:10.47 ksoftirqd/0
5649 root 20 0 157584 2004 1480 R 5.6 0.2 0:00.04 top
[root@localhost ~]#
一次性输出所有信息而非动态显示。
SAR命令
查看网卡流量
[root@localhost ~]# sar -n DEV
Linux 3.10.0-693.el7.x86_64 (localhost.localdomain) 2018年05月31日 _x86_64_ (1 CPU)
[root@localhost ~]# sar -n DEV 1 3
Linux 3.10.0-693.el7.x86_64 (localhost.localdomain) 2018年05月31日 _x86_64_ (1 CPU)
12时44分19秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
12时44分20秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12时44分20秒 ens33 6.19 1.03 0.36 0.20 0.00 0.00 0.00
12时44分20秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
12时44分21秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12时44分21秒 ens33 4.12 1.03 0.24 0.41 0.00 0.00 0.00
12时44分21秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
12时44分22秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12时44分22秒 ens33 1.03 1.03 0.06 0.41 0.00 0.00 0.00
平均时间: IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
平均时间: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: ens33 3.78 1.03 0.22 0.34 0.00 0.00 0.00
[root@localhost ~]#
sar -n DEV 1 3 表示每隔一秒打印一次,共三次。
sar -n DEV 会把当天的记录的网卡信息打印出来,每隔10分钟记录一次。
IFACE这一列表示设备名称,rxpck/s 这一列表示每秒进入收取的包的数量,txpck/s 这一列表示每秒发送出去的包的数量,rxkB/s 表示每秒收取的数据量,txkB/s 表示每秒发送的数据量。
-f 选项,后面跟文件名, 查看某天的流量历史
[root@localhost ~]# sar -n DEV -f /var/log/sa/sa31
Linux 3.10.0-693.el7.x86_64 (localhost.localdomain) 2018年05月31日 _x86_64_ (1 CPU)
12时40分02秒 IFACE rxpck/s txpck/s rxkB/s txkB/s rxcmp/s txcmp/s rxmcst/s
12时50分01秒 lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
12时50分01秒 ens33 1.83 0.20 0.12 0.03 0.00 0.00 0.00
平均时间: lo 0.00 0.00 0.00 0.00 0.00 0.00 0.00
平均时间: ens33 1.83 0.20 0.12 0.03 0.00 0.00 0.00
[root@localhost ~]#
sar库文件 一定在 /var/log/sa/ 下
历史负载
[root@localhost ~]# sar -q
Linux 3.10.0-693.el7.x86_64 (localhost.localdomain) 2018年05月31日 _x86_64_ (1 CPU)
12时40分02秒 runq-sz plist-sz ldavg-1 ldavg-5 ldavg-15 blocked
12时50分01秒 0 102 0.00 0.03 0.08 0
平均时间: 0 102 0.00 0.03 0.08 0
[root@localhost ~]#
-b 查看磁盘
[root@localhost ~]# sar -b
Linux 3.10.0-693.el7.x86_64 (localhost.localdomain) 2018年05月31日 _x86_64_ (1 CPU)
12时40分02秒 tps rtps wtps bread/s bwrtn/s
12时50分01秒 0.11 0.00 0.11 0.00 1.27
平均时间: 0.11 0.00 0.11 0.00 1.27
[root@localhost ~]#
nload命令
系统没有默认安装它,安装如下:yum install epel-release -y ;yum install nload -y
查看网卡流量
直接输入 nload 命令 就会清晰直观的出现如上界面。
最上面一行是网卡名字及ip地址,按右箭头可以查看其它网卡网络流量。
输出结果为2部分,ifcoming 为进入网卡的流量,outgoing为网卡出去的流量。按q退出该界面。
free命令
查看内存使用状况
[root@localhost ~]# free
total used free shared buff/cache available
Mem: 1008152 106636 465900 7032 435616 712284
Swap: 2097148 0 2097148
[root@localhost ~]#
total:内存总大小
used:真正使用的实际内存大小
free:剩余物理内存大小
shared:共享内存大小
buff/cache:分配给buff和ceche的内存总部有多大,数据经过CPU计算,即将要写入磁盘,这时用的内存buffer;CPU要计算时,需要把数据从磁盘中读取出来,临时放到内存中,这部分内存为cache。
available:系统可使用内存有多大,包含free
隐藏公式:total=used+free+buff/cache。 available由free这部分内存和buff/cache未被占用的内存组成。
free -m 以MB为单位打印内存的使用情况
free -g 以GB为单位打印内存额使用情况
free -h 在打印出来的内存数字后面加上单位
监控io性能
[root@localhost ~]# iostat
Linux 3.10.0-693.el7.x86_64 (localhost.localdomain) 2018年05月31日 _x86_64_ (1 CPU)
avg-cpu: %user %nice %system %iowait %steal %idle
0.08 0.00 0.36 0.03 0.00 99.54
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
sda 0.16 1.29 4.63 167858 600426
scd0 0.00 0.26 0.00 34280 0
[root@localhost ~]#
%util 这列是表示磁盘io使用 占CPU百分比
动态显示占用磁盘io内存多的 进程
PS命令
显示系统进程
[root@localhost ~]# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.6 128164 6828 ? Ss 5月30 0:34 /usr/lib/systemd/systemd --switched-root
root 2 0.0 0.0 0 0 ? S 5月30 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? S 5月30 0:11 [ksoftirqd/0]
root 5 0.0 0.0 0 0 ? S< 5月30 0:00 [kworker/0:0H]
root 7 0.0 0.0 0 0 ? S 5月30 0:00 [migration/0]
root 8 0.0 0.0 0 0 ? S 5月30 0:00 [rcu_bh]
root 9 0.0 0.0 0 0 ? S 5月30 0:07 [rcu_sched]
root 10 0.0 0.0 0 0 ? S 5月30 0:23 [watchdog/0]
root 12 0.0 0.0 0 0 ? S 5月30 0:00 [kdevtmpfs]
ps aux 与 ps -elf 显示的信息 基本一样。
PID :表示进程的ID
Stat:进程的状态。状态分以下几种:
D:不能中断的进程(进程为IO)。
R(run):正在运行中的进程,其中包括了等待CPU时间片的进程。
S(sleep):已经中断的进程。通常情况下,系统的大部分进程都是这个状态。
T:已经停止或者暂停的进程。
W:(内核2.6xx以后不可用) 没有足够内存页分配
X:已经死掉的进程
Z:僵尸进程
<:高优先级进程
N:低优先级进程
L:在内存中被锁了内存分页
s:主进程
l:多线程进程
+:在前台运行的进程
grep过滤
[root@localhost ~]# ps aux | grep 'sshd'
root 871 0.0 0.4 105996 4120 ? Ss 5月30 0:00 /usr/sbin/sshd -D
root 5734 0.1 0.5 145700 5196 ? Ss 12:32 0:05 sshd: root@pts/1
root 6127 0.0 0.0 112676 984 pts/1 S+ 13:48 0:00 grep --color=auto sshd
[root@localhost ~]# ps aux | grep -c 'sshd'
3
[root@localhost ~]#
实际进程为2个,因为grep也算了一个进程。
netstat命令
查看网络状况
ss-an 与 netstat 异曲同工
查看系统启动了哪些端口
[root@localhost ~]# netstat -lnp | head
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1692/nginx: master
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 874/httpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 871/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 970/master
tcp6 0 0 :::8080 :::* LISTEN 1692/nginx: master
tcp6 0 0 :::22 :::* LISTEN 871/sshd
tcp6 0 0 ::1:25 :::* LISTEN 970/master
udp 0 0 127.0.0.1:323 0.0.0.0:* 511/chronyd
[root@localhost ~]#
查看网络连接状况
[root@localhost ~]# netstat -an | head
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 52 192.168.1.180:22 192.168.1.150:49905 ESTABLISHED
tcp6 0 0 :::8080 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
tcp6 0 0 ::1:25 :::* LISTEN
[root@localhost ~]#
打印 各 State 的数量
[root@localhost ~]# netstat -an | awk '/^tcp/ {++sta[$NF]} END {for(key in sta) print key,"\t",sta[key]}'
LISTEN 7
ESTABLISHED 1
[root@localhost ~]#
抓包工具
tcpdump工具
yum install tcpdump -y
tcpdump -nn -i ens33
输入命令后,会出现一大堆字符串,按 CTRL+C 退出。刷屏越快,代表网卡上的数据包越多。
-i 后面跟 设备名称 -nn 作用让第三列和第四列显示为 ‘IP+端口号’的形式,如果不加 -nn,则显示‘主机名+服务名称’。
-c 指定抓包数量,数量够了,自动退出。
tcpdump -nn -i ens33 port 22 -c 3
指定只抓端口为22的包 且只抓3个包
[root@localhost ~]# tcpdump -nn -i ens33 port 22 -c 3
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
14:21:24.089818 IP 192.168.1.180.22 > 192.168.1.150.49905: Flags [P.], seq 3914226102:3914226314, ack 1402884578, win 251, length 212
14:21:24.091783 IP 192.168.1.150.49905 > 192.168.1.180.22: Flags [.], ack 212, win 16071, length 0
14:21:24.093197 IP 192.168.1.180.22 > 192.168.1.150.49905: Flags [P.], seq 212:504, ack 1, win 251, length 292
3 packets captured
3 packets received by filter
0 packets dropped by kernel
[root@localhost ~]#
tcpdump -nn -i ens33 tcp and not port 22 指定抓tcp的包,但不要22端口的
tcpdump -nn -i ens33 port 22 and port 66 指定抓22和66端口的包
tcpdump -nn -i ens33 not port 22 and host 192.168.1.180 抓ip为192.168.1.180 但不要22端口的包
-w 存入至文件中
[root@localhost ~]# tcpdump -nn -i ens33 port 22 -c 3 -w 33.txt
tcpdump: listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
3 packets captured
3 packets received by filter
0 packets dropped by kernel
[root@localhost ~]#
不能直接cat查看
[root@localhost ~]# cat 33.txt
Ճ²¡͕[Jˊ¥q
<@@¨U(´(ñ蒂SsþP讂��½6l��®6溚z
��듂¸
£YN\ר垹��髦§Iݒ;��䊌ꘔ|@Ѓi��dv��*²¬©3hQ
&+մzۧD��µݟFk��ⅈEԍXxav[肍[m<<
)퀥E(VI@퀨(´ñSsþ蒂P?XµTە[綪j
)퀥E\VT@((´ñSsþ蒂P?X)þ/&9\²
z
ط,ڙ��ࠟ¼¶|bZªԝu��¥iI!XshellXshell[root@localhost ~]# XshellXshell
-bash: XshellXshell: 未找到命令
[root@localhost ~]# file 33.txt
33.txt: tcpdump capture file (little-endian) - version 2.4 (Ethernet, capture length 262144)
[root@localhost ~]#
tcpdump -r 查看
[root@localhost ~]# tcpdump -r 33.txt
reading from file 33.txt, link-type EN10MB (Ethernet)
14:27:25.364362 IP localhost.localdomain.ssh > 192.168.1.150.49905: Flags [P.], seq 3914449410:3914449558, ack 1402893310, win 251, length 148
14:27:25.366445 IP 192.168.1.150.49905 > localhost.localdomain.ssh: Flags [.], ack 148, win 16216, length 0
14:27:39.489448 IP 192.168.1.150.49905 > localhost.localdomain.ssh: Flags [P.], seq 1:53, ack 148, win 16216, length 52
[root@localhost ~]#
Wireshark 工具
yum install wireshark -y
[root@localhost ~]# 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'
tshark: -R without -2 is deprecated. For single-pass filtering use -Y.
Running as user "root" and group "root". This could be dangerous.
Capturing on 'bluetooth0'
c^C0 packets captured
[root@localhost ~]#
由于机器没有开启web服务,不会显示任何内容。
这命令显示的内容 类似于 web的访问日志,若服务器没有配置访问日志,可以临时使用改命令去查看下当前服务器上的web请求。
Linux网络相关
ifconifg
查看网卡IP信息
如没有此命令,yum install net-tools -y
[root@localhost ~]# ifconfig
ens33: flags=4163 mtu 1500
inet 192.168.1.180 netmask 255.255.255.0 broadcast 192.168.1.255
ether 00:0c:29:95:8a:ed txqueuelen 1000 (Ethernet)
RX packets 116523 bytes 89340416 (85.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 41583 bytes 13023965 (12.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1 (Local Loopback)
RX packets 212 bytes 20604 (20.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 212 bytes 20604 (20.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@localhost ~]#
ip addr 查看所有网卡
[root@localhost ~]# ip addr
1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:95:8a:ed brd ff:ff:ff:ff:ff:ff
inet 192.168.1.180/24 brd 192.168.1.255 scope global ens33
valid_lft forever preferred_lft forever
[root@localhost ~]#
ifup ens33 启动ens33网卡 ifdown ens33 停用ens33网卡
重启网卡命令: systemctl restart network
设定虚拟网卡ens33:1
[root@localhost network-scripts]# cat ifcfg-ens33:1
TYPE=Ethernet
BOOTPROTO=static
NAME=ens33:1
DEVICE=ens33:1
ONBOOT=yes
IPADDR=192.168.1.181
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=114.114.114.114
DNS2=8.8.8.8
[root@localhost network-scripts]#
ifconfig 再次查看信息
[root@localhost network-scripts]# ifconfig
ens33: flags=4163 mtu 1500
inet 192.168.1.180 netmask 255.255.255.0 broadcast 192.168.1.255
ether 00:0c:29:95:8a:ed txqueuelen 1000 (Ethernet)
RX packets 117211 bytes 89409498 (85.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 42002 bytes 13077069 (12.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ens33:1: flags=4163 mtu 1500
inet 192.168.1.181 netmask 255.255.255.0 broadcast 192.168.1.255
ether 00:0c:29:95:8a:ed txqueuelen 1000 (Ethernet)
lo: flags=73 mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1 (Local Loopback)
RX packets 212 bytes 20604 (20.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 212 bytes 20604 (20.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@localhost network-scripts]#
即可见 ens:1 网卡已有。
mii-tool ens33
查看网卡连接状态
[root@localhost network-scripts]# mii-tool ens33
ens33: negotiated 1000baseT-FD flow-control, link ok
[root@localhost network-scripts]#
link状态表示已连接状态。
ethtool ens33
也可查看网卡连接状态
[root@localhost network-scripts]# ethtool ens33
Settings for ens33:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
MDI-X: off (auto)
Supports Wake-on: d
Wake-on: d
Current message level: 0x00000007 (7)
drv probe link
Link detected: yes
[root@localhost network-scripts]#
link detected 状态为 yes 代表已连接
DNS配置文件
dns配置文件为/etc/resolv.conf
[root@localhost network-scripts]# cat /etc/resolv.conf
Generated by NetworkManager
nameserver 114.114.114.114
nameserver 8.8.8.8
[root@localhost network-scripts]#
临时更改DNS IP地址,可以去上面的文件里修改。永久生效还是得去网卡的配置文件里
/etc/hosts
可以解析域名,需要手动去添加,操作如下
[root@localhost network-scripts]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[root@localhost network-scripts]# vim /etc/hosts
[root@localhost network-scripts]# cat !$
cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.180 www.lantern.com
[root@localhost network-scripts]# ping www.lantern.com
PING www.lantern.com (192.168.1.180) 56(84) bytes of data.
64 bytes from www.lantern.com (192.168.1.180): icmp_seq=1 ttl=64 time=0.332 ms
64 bytes from www.lantern.com (192.168.1.180): icmp_seq=2 ttl=64 time=0.054 ms
^C
--- www.lantern.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.054/0.193/0.332/0.139 ms
[root@localhost network-scripts]#
/etc/hosts格式很简单,一行一个记录。分2部分。第一部分是IP,第二部分是域名。
需要注意的是:
TCP三次握手四次挥手: http://www.doc88.com/p-9913773324388.html
tshark几个用法: http://www.aminglinux.com/bbs/thread-995-1-1.html