方法一

使用默认自带的ip命令

ip addr

输出:

3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether b0:fc:36:5b:41:ff brd ff:ff:ff:ff:ff:ff
    inet 192.168.31.148/24 brd 192.168.31.255 scope global dynamic noprefixroute wlp3s0
       valid_lft 39246sec preferred_lft 39246sec
    inet6 fe80::4d81:ae75:7737:71e4/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

可以看到ip是192.168.31.148

方法二

ifconfig不是默认就有的,所以需要先安装再使用

sudo apt-get install net-tools

输出:

wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.31.148  netmask 255.255.255.0  broadcast 192.168.31.255
        inet6 fe80::4d81:ae75:7737:71e4  prefixlen 64  scopeid 0x20<link>
        ether b0:fc:36:5b:41:ff  txqueuelen 1000  (Ethernet)
        RX packets 95756  bytes 86474809 (86.4 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 61431  bytes 9585430 (9.5 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0