• Linux常用命令(6)网络通信命令


    1、命令名称:write

      执行权限:所有用户

      功能描述:向另外一个用户发送信息,以CTRL+D作为结束

      语法:write <用户名>

    root向luxh用户发送信息
    
    [root@localhost ~]# write luxh
    write: luxh is logged in more than once; writing to pts/1
    hello,luxh,i am root
    
    用户luxh接收到的信息为
    [luxh@localhost ~]$ 
    Message from luxh@localhost.localdomain (as root) on pts/0 at 05:17 ...
    hello,luxh,i am root

      root用户向luxh用户发送信息,luxh用户必须已经登陆,否则是发送不了的。

    2、命令名称:wall

      执行权限:所有用户

      功能描述:向所有用户广播信息

      语法:wall [message]  [文件名]

    root向所有登陆用户发送信息
    
    [root@localhost ~]# wall Happy New Year
    
    Broadcast message from root@localhost.localdomain (pts/0) (Thu Nov 22 05:27:49 2012):
    
    Happy New Year
    [root@localhost ~]#
    
    已登陆的用户就可以收到
    [luxh@localhost ~]$ 
    Broadcast message from root@localhost.localdomain (pts/0) (Thu Nov 22 05:27:49 2012):
    
    Happy New Year

    3、命令名称:ping

      执行权限:root

      功能描述:测试网络连通性

      语法:ping [选项]  IP地址

    在Linux下直接ping ID,按CTRL+C终止命令,否则会一直ping
    [root@localhost ~]# ping 192.168.1.1 PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. 64 bytes from 192.168.1.1: icmp_seq=1 ttl=128 time=6.66 ms 64 bytes from 192.168.1.1: icmp_seq=2 ttl=128 time=6.63 ms 64 bytes from 192.168.1.1: icmp_seq=3 ttl=128 time=3.13 ms 64 bytes from 192.168.1.1: icmp_seq=4 ttl=128 time=4.55 ms 64 bytes from 192.168.1.1: icmp_seq=5 ttl=128 time=6.69 ms 64 bytes from 192.168.1.1: icmp_seq=6 ttl=128 time=5.90 ms 64 bytes from 192.168.1.1: icmp_seq=7 ttl=128 time=2.77 ms 64 bytes from 192.168.1.1: icmp_seq=8 ttl=128 time=2.75 ms 64 bytes from 192.168.1.1: icmp_seq=9 ttl=128 time=5.41 ms 64 bytes from 192.168.1.1: icmp_seq=10 ttl=128 time=7.52 ms

      

     使用 -c 指定ping的次数
    [luxh@localhost ~]$ ping -c 4 192.168.1.1 PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. 64 bytes from 192.168.1.1: icmp_seq=1 ttl=128 time=6.49 ms 64 bytes from 192.168.1.1: icmp_seq=2 ttl=128 time=5.42 ms 64 bytes from 192.168.1.1: icmp_seq=3 ttl=128 time=2.46 ms 64 bytes from 192.168.1.1: icmp_seq=4 ttl=128 time=3.69 ms --- 192.168.1.1 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3010ms rtt min/avg/max/mdev = 2.464/4.520/6.498/1.551 ms [luxh@localhost ~]$
    使用 -s 指定发送包的大小,最大不能超过65507字节
    [root@localhost ~]# ping -c 4 -s 1024 192.168.1.1 PING 192.168.1.1 (192.168.1.1) 1024(1052) bytes of data. 1032 bytes from 192.168.1.1: icmp_seq=1 ttl=128 time=6.67 ms 1032 bytes from 192.168.1.1: icmp_seq=2 ttl=128 time=4.21 ms 1032 bytes from 192.168.1.1: icmp_seq=3 ttl=128 time=9.06 ms 1032 bytes from 192.168.1.1: icmp_seq=4 ttl=128 time=5.09 ms --- 192.168.1.1 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3010ms rtt min/avg/max/mdev = 4.212/6.262/9.064/1.845 ms [root@localhost ~]#

      

    4、命令名称:ifconfig

      执行权限:root

      功能描述:查看网络设置信息

      语法:ifconfig [-a]  [网卡设备标识]

          -a  显示所有网卡的信息 (在Linux系统中可以省略,在Unix系统中不能省略)

    [root@localhost ~]# ifconfig
    eth0      Link encap:Ethernet  HWaddr 00:0C:29:4C:63:3E  
              inet addr:192.168.0.102  Bcast:192.168.0.255  Mask:255.255.255.0
              inet6 addr: fe80::20c:29ff:fe4c:633e/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:4238 errors:0 dropped:0 overruns:0 frame:0
              TX packets:3578 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:4560042 (4.3 MiB)  TX bytes:299603 (292.5 KiB)
              Interrupt:19 Base address:0x2024 
    
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:16436  Metric:1
              RX packets:8 errors:0 dropped:0 overruns:0 frame:0
              TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:480 (480.0 b)  TX bytes:480 (480.0 b)

       eth0是实际的物理网卡,lo是虚拟的回环地址网卡

    临时改变IP地址,重启后无效
    [root@localhost ~]# ifconfig eth0 192.168.1.5
  • 相关阅读:
    Ubuntu18.04安装Virtualenv虚拟环境
    SQLite3学习笔记----创建数据库的两种方式
    Git学习笔记-----下载GitHub上某个分支的代码
    Git学习笔记——从一台电脑上传文件到Github上
    plsql配置数据库连接
    Java与各种数据库连接代码
    marquee上下左右循环无缝滚动代码
    仅用aspx文件实现Ajax调用后台cs程序。(实例)
    MVC 5使用TempData(对象)跨视图传递数据
    SQL Server中查询数据库及表的信息语句
  • 原文地址:https://www.cnblogs.com/luxh/p/2783362.html
Copyright © 2020-2023  润新知