Linux命令——网络命令

来源:互联网 发布:淘宝轮毂能买吗 编辑:程序博客网 时间:2024/06/05 12:50

常用的网络命令

write   发送信息wall    发送信息ping    ifconfigmail    发送邮件last    查看用户登录日志traceroute  跟踪netstat 查看网络状态setup   设置网络mount   挂载命令
  • write

    • 给登录在服务器指定的用户发信息
    • ctrl+退格 回退
    • ctrl+D保存退出
  • wall

    • 给所有登录的用户发送信息
  • ping

    • 远程的探测命令或踩点命令
    • ping ip地址

      [root@VM_134_231_centos ~]# ping www.baidu.comPING www.a.shifen.com (14.215.177.37) 56(84) bytes of data.64 bytes from 14.215.177.37: icmp_seq=1 ttl=55 time=3.80 ms64 bytes from 14.215.177.37: icmp_seq=2 ttl=55 time=3.83 ms[root@VM_134_231_centos ~]# ping -c 3 www.baidu.comPING www.a.shifen.com (220.181.112.244) 56(84) bytes of data.64 bytes from 220.181.112.244: icmp_seq=1 ttl=52 time=38.7 ms64 bytes from 220.181.112.244: icmp_seq=2 ttl=52 time=38.8 ms64 bytes from 220.181.112.244: icmp_seq=3 ttl=52 time=38.7 ms
  • ifconfig

    • 查看网络信息

      [root@localhost ~]# ifconfig
    • 修改IP地址

      [root@localhost ~]# ifconfig eth0 192.168.1.1
  • mail

    • 发送邮件

      • mail 用户名

        [root@localhost ~]# mail root
    • 查看邮件

      • mail

        • 序列号 查看第封邮件
        • h 目录
        • delete 序号 删除邮件
      [root@localhost ~]# mailHeirloom Mail version 12.4 7/29/08.  Type ? for help."/var/spool/mail/root": 1 message 1 new>N  1 root                  Mon Mar  6 07:26  18/597   "Test"& 1
  • last

    • 统计用户登录的信息
    [root@VM_134_231_centos ~]# lastroot     pts/0        110.209.142.75   Sun Mar  5 23:24   still logged in   root     pts/0        110.209.142.75   Sun Mar  5 22:09 - 22:45  (00:35)    root     pts/0        110.209.142.75   Sun Mar  5 22:07 - 22:09  (00:02)    root     pts/0        110.209.142.75   Sun Mar  5 20:27 - 21:53  (01:26)    root     pts/0        111.151.180.193  Thu Mar  2 00:41 - 00:51  (00:10)   
    • lastlog

    • 查看单个用户最后一次的登录日记

      • lastlog -u 502
  • traceroute

    • 访问路径跟踪

      traceroute www.baidu.com
  • netstat

    -查询网络状态

    -t :    TCP协议-u :    UDP协议-l :    监听-r :    路由-n :    显示IP地址和端口号
    netstat -tlun   查看本机监听的端口netstat -an     查看本机所有的网络链接netstat -rn     查看本机路由表
    • 实例
    [root@VM_134_231_centos ~]# netstat -tlunActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address               Foreign Address             State      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      [root@VM_134_231_centos ~]# netstat -rnKernel IP routing tableDestination     Gateway         Genmask         Flags   MSS Window  irtt Iface10.135.128.0    0.0.0.0         255.255.192.0   U         0 0          0 eth0169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth00.0.0.0         10.135.128.1    0.0.0.0         UG        0 0          0 eth0[root@VM_134_231_centos ~]# 
  • setup

    • 配置网络信息,红帽子系列的linux特有的命令
  • mount

    • 挂载命令
    • 语法

      • mount [-t 文件系统] 设备名称 挂载点

        • 光盘默认的设备名称:/dev/sr0
          [root@localhost ~]# mkdir /mnt/cdrom[root@localhost ~]# ls /mntcdrom[root@localhost ~]# mount -t iso9660 /dev/sr0 /mnt/cdrommount: block device /dev/sr0 is write-protected, mounting read-only[root@localhost ~]# 
    • 卸载

      • 不能在其挂载点下卸载
        [root@localhost cdrom]# unmount /dev/sr0-bash: unmount: command not found[root@localhost cdrom]# umount /dev/sr0umount: /mnt/cdrom: device is busy.(In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))[root@localhost cdrom]# cd /[root@localhost /]# umount /dev/sr0
0 0
原创粉丝点击