Linux 学习- Ubuntu 查看本机IP

在Ubuntu下,查看本机IP的指令是:

ifconfig

但是,可能刚开始,你并不能直接使用该命令,此时,你需要install net-tools, 命令:sudo apt install net-tools
当然,这个工具已经被弃用了,但是不影响我当下的使用。有兴趣可以了解下iproute2,可参考文章:net-tools与iproute2大比较

2789632-8f95e2fe259dacb7.png

zzh@zzh-K56CM:~$ ifconfig -a

Command 'ifconfig' not found, but can be installed with:

sudo apt install net-tools

zzh@zzh-K56CM:~$ sudo apt install net-tools
[sudo] zzh 的密码: 
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
下列软件包是自动安装的并且现在不需要了:
  linux-headers-4.18.0-15
使用'sudo apt autoremove'来卸载它(它们)。
下列【新】软件包将被安装:
  net-tools
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 182 个软件包未被升级。
需要下载 194 kB 的归档。
解压缩后会消耗 803 kB 的额外空间。
获取:1 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 net-tools amd64 1.60+git20161116.90da8a0-1ubuntu1 [194 kB]
已下载 194 kB,耗时 7秒 (29.8 kB/s)                                            
N: 忽略‘google-chrome.list.1’(于目录‘/etc/apt/sources.list.d/’),鉴于它的文件扩展名无效
正在选中未选择的软件包 net-tools。
(正在读取数据库 ... 系统当前共安装有 178971 个文件和目录。)
正准备解包 .../net-tools_1.60+git20161116.90da8a0-1ubuntu1_amd64.deb  ...
正在解包 net-tools (1.60+git20161116.90da8a0-1ubuntu1) ...
正在处理用于 man-db (2.8.3-2ubuntu0.1) 的触发器 ...
正在设置 net-tools (1.60+git20161116.90da8a0-1ubuntu1) ...
N: 忽略‘google-chrome.list.1’(于目录‘/etc/apt/sources.list.d/’),鉴于它的文件扩展名无效

这个时候,我们就可以使用命令查看我们本机的IP啦~


2789632-1bde76a6aea3cba2.png
zzh@zzh-K56CM:~$ ifconfig -a
enp4s0f2: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 74:d0:2b:17:0b:63  txqueuelen 1000  (以太网)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        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  (本地环回)
        RX packets 1032  bytes 91888 (91.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1032  bytes 91888 (91.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.4  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::1341:7153:28f3:d4e9  prefixlen 64  scopeid 0x20<link>
        ether 6c:71:d9:8e:a1:1a  txqueuelen 1000  (以太网)
        RX packets 61601  bytes 77337649 (77.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 32051  bytes 4702276 (4.7 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
2789632-e934aeb9df00bd06.png

2789632-92b25cd536a36cfb.png
  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值