演示环境
$ uname -a
Linux xxxxx-xxxxx-xxxx5.4.0-47-generic #51-Ubuntu SMP Fri Sep 4 19:50:52 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
1.关于
重装完系统,发现没有命令ifconfig
$ ifconfig
zsh: command not found: ifconfig
2.检查是否存在该命令
自己使用了ohmyzsh
,检查配置文件的PATH
中是否包含sbin
目录,还需要检查sbin
目录下是否存在ifconfig
命令。
3.安装
- 3.1 安装命令
$ sudo apt-get install ifconfig
失败,提示找不到该包
$ sudo apt-get install ifconfig
[sudo] password for cube:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package ifconfig
*3.2 正确安装指令
ifconfig
包含在net-tools
中,该库还包含其他命令:whois
sudo apt-get install net-tools
安装结果
$ sudo apt-get install net-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
net-tools
0 upgraded, 1 newly installed, 0 to remove and 104 not upgraded.
Need to get 196 kB of archives.
After this operation, 864 kB of additional disk space will be used.
Get:1 http://mirrors.aliyun.com/ubuntu focal/main amd64 net-tools amd64 1.60+git20180626.aebd88e-1ubuntu1 [196 kB]
Fetched 196 kB in 12s (16.6 kB/s)
Selecting previously unselected package net-tools.
(Reading database ... 166990 files and directories currently installed.)
Preparing to unpack .../net-tools_1.60+git20180626.aebd88e-1ubuntu1_amd64.deb ...
Unpacking net-tools (1.60+git20180626.aebd88e-1ubuntu1) ...
Setting up net-tools (1.60+git20180626.aebd88e-1ubuntu1) ...
Processing triggers for man-db (2.9.1-1) ...
4.使用ifconfig
$ ifconfig
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 151 bytes 13005 (13.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 151 bytes 13005 (13.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 00