Linux常用命令-网络命令
write 给用户发信息
eg: //发信息
[root@localhost ~]# write qq
write: qq is logged in more than once; writing to pts/1
happy new year!
2020/1/24
//收信息
[qq@localhost ~]$
Message from root@localhost.localdomain on pts/0 at 12:37 ...
happy new year!
2020/1/24
EOF
//注意发信息时用ctrl+backspace或是delete删除错误内容,ctrl+d发送信息
wall 给所有用户发信息
eg: //发件
[root@localhost ~]# wall
happy new year! every!
nacl
2020/1/24[root@localhost ~]#
Broadcast message from root@localhost.localdomain (pts/0) (Fri Jan 24 12:44:01 2020):
happy new year! every!
nacl
2020/1/24
//收件人
[qq@localhost ~]$
Broadcast message from root@localhost.localdomain (pts/0) (Fri Jan 24 12:44:01 2020):
happy new year! every!
nacl
2020/1/24
ping 测试网络连通性
eg: [root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (14.215.177.38) 56(84) bytes of data.
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=1 ttl=55 time=51.9 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=2 ttl=55 time=52.5 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=3 ttl=55 time=51.6 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=4 ttl=55 time=52.0 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=5 ttl=55 time=54.2 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=6 ttl=55 time=52.3 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=7 ttl=55 time=52.0 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=8 ttl=55 time=54.1 ms
//如果不主动停止,系统会不断ping 我们可以使用-c 指定ping的次数
eg: [root@localhost ~]# ping -c 4 spring.io
PING spring.io (104.20.5.247) 56(84) bytes of data.
64 bytes from 104.20.5.247 (104.20.5.247): icmp_seq=1 ttl=54 time=190 ms
64 bytes from 104.20.5.247 (104.20.5.247): icmp_seq=2 ttl=54 time=190 ms
64 bytes from 104.20.5.247 (104.20.5.247): icmp_seq=3 ttl=54 time=195 ms
64 bytes from 104.20.5.247 (104.20.5.247): icmp_seq=4 ttl=54 time=241 ms
--- spring.io ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 190.223/204.531/241.846/21.639 ms
ifconfig 查看和配置网卡信息
//查看网卡信息
eg:[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.5 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 240e:be:3410:cc00:e1e5:2f53:ddc9:4430 prefixlen 64 scopeid 0x0<global>
inet6 fe80::79c:dd1e:6996:f753 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:13:b2:02 txqueuelen 1000 (Ethernet)
RX packets 91197 bytes 7579405 (7.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 98529 bytes 12995380 (12.3 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 36 bytes 3048 (2.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 36 bytes 3048 (2.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
ifconfig -a //十进制形式看inet
mail 发送邮件查看邮件
//发邮件
[root@localhost ~]# mail qq
Subject: happy new year
Today is the last day of 2020 ,happy new year!
nacl
2020/1/24EOT
//若mail命令无效,可使用yum install mailx安装mail
last 查看用户登录信息
eg:[root@localhost ~]# last
root pts/0 192.168.1.4 Fri Jan 24 13:03 still logged in
qq pts/0 192.168.1.4 Fri Jan 24 13:02 - 13:02 (00:00)
qq pts/1 192.168.1.4 Fri Jan 24 13:01 - 13:01 (00:00)
qq pts/1 192.168.1.4 Fri Jan 24 13:00 - 13:01 (00:01)
qq pts/1 192.168.1.4 Fri Jan 24 12:59 - 13:00 (00:00)
root pts/0 192.168.1.4 Fri Jan 24 12:46 - 13:01 (00:15)
root tty1 Fri Jan 24 12:45 still logged in
qq pts/1 192.168.1.4 Fri Jan 24 12:34 - 12:59 (00:24)
root pts/0 192.168.1.4 Fri Jan 24 12:33 - 12:44 (00:10)
qq pts/3 192.168.1.4 Thu Jan 23 19:59 - 13:00 (17:00)
qq pts/3 192.168.1.4 Thu Jan 23 19:56 - 19:56 (00:00)
root pts/2 192.168.1.4 Thu Jan 23 18:37 - 13:00 (18:22)
qq pts/0 192.168.1.4 Thu Jan 23 14:04 - 20:48 (06:43)
qq pts/0 192.168.1.4 Thu Jan 23 14:00 - 14:02 (00:01)
root pts/1 192.168.1.4 Thu Jan 23 12:21 - 20:48 (08:27)
root pts/1 192.168.1.4 Wed Jan 22 16:58 - 17:49 (00:51)
root pts/0 192.168.1.4 Wed Jan 22 13:28 - 13:37 (1+00:08)
root pts/2 192.168.1.4 Mon Jan 20 14:45 - 18:20 (03:35)
root pts/1 192.168.1.4 Mon Jan 20 14:02 - 14:46 (00:44)
root pts/0 192.168.1.4 Mon Jan 20 14:02 - 14:46 (00:44)
root pts/2 fool.lan Sun Jan 19 21:22 - 21:24 (00:01)
root pts/1 fool.lan Sun Jan 19 20:40 - 21:37 (00:57)
root pts/0 fool.lan Sun Jan 19 20:40 - 21:37 (00:57)
root tty1 Sun Jan 19 20:39 - 12:45 (4+16:06)
reboot system boot 3.10.0-1062.el7. Sun Jan 19 20:37 - 13:03 (4+16:26)
root pts/3 fool.lan Sun Jan 19 20:37 - crash (00:00)
root pts/2 fool.lan Sun Jan 19 20:37 - crash (00:00)
root pts/3 fool.lan Sun Jan 19 20:36 - 20:36 (00:00)
root pts/2 fool.lan Sun Jan 19 20:36 - 20:36 (00:00)
root pts/1 fool.lan Sun Jan 19 20:31 - crash (00:06)
root pts/0 fool.lan Sun Jan 19 20:31 - crash (00:06)
root tty1 Sun Jan 19 20:29 - 20:38 (00:09)
reboot system boot 3.10.0-1062.el7. Sun Jan 19 20:28 - 13:03 (4+16:35)
wtmp begins Sun Jan 19 20:28:06 2020
lastlog 查看用户最后一次登录信息
eg:[root@localhost ~]# lastlog
Username Port From Latest
root pts/0 192.168.1.4 Fri Jan 24 13:03:49 +0800 2020
bin **Never logged in**
daemon **Never logged in**
adm **Never logged in**
lp **Never logged in**
sync **Never logged in**
shutdown **Never logged in**
halt **Never logged in**
mail **Never logged in**
operator **Never logged in**
games **Never logged in**
ftp **Never logged in**
nobody **Never logged in**
systemd-network **Never logged in**
dbus **Never logged in**
polkitd **Never logged in**
sshd **Never logged in**
postfix **Never logged in**
qq pts/0 192.168.1.4 Fri Jan 24 13:02:03 +0800 2020
java **Never logged in**
traceroute 跟踪有主机到访问地址的路径
eg:[root@localhost ~]# traceroute www.baidu.com
traceroute to www.baidu.com (14.215.177.39), 30 hops max, 60 byte packets
1 gateway (192.168.1.1) 2.647 ms 2.471 ms 3.336 ms
2 100.75.0.1 (100.75.0.1) 7.499 ms 7.623 ms 7.834 ms
3 10.225.50.9 (10.225.50.9) 10.896 ms 10.225.50.25 (10.225.50.25) 11.852 ms 11.918 ms
4 219.145.193.1 (219.145.193.1) 17.953 ms
netstat 查看网络相关信息
netstat //查看网络相关信息
-t //tcp协议
-u //udp协议
-l //监听
-r //路由
-n //显示ip地址和端口号
常用命令: netstat -tlun //查看本机监听的端口
netstat -an //查看本机所有网络连接
netstat -rn //查看本机路由表
setup redhat专用网络配置
setup //redhat系列专用网络配置工具
//若电脑上未安装setup 可使用 yum install setuptool安装工具
使用命令进入设置然后run tool
然后就可以设置相关信息
特点:与ifconfig不同,它的设置永久生效,而ifconfig的设置重启后失效
mount 挂载命令
mount [挂载物][挂载点]//挂载命令
//挂载
[root@localhost ~]# ls /mnt/
[root@localhost ~]# mkdir /mnt/cdrom
[root@localhost ~]# ls /mnt/
cdrom
[root@localhost ~]# mount /dev/sr0 /mnt/cdrom
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]# cd /mnt/cdrom
[root@localhost cdrom]# ls
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
//退出
[root@localhost cdrom]# cd /
[root@localhost /]# umount /dev/sr0