Have you tried to run ifconfig on your terminal but when you press enter, you got some error like this, Command ‘ifconfig’ not found. It’s not surprising that many Linux users have encountered the same problem. But don’t worry, because in this article you will fix that problem and you can use ifconfig normally.
Let’s look closer at what actually causing the Command ‘ifconfig’ not found problem. The ifconfig command is part of a package called net-tools. So when the net-tools package is not installed on your machine, you cannot run the ifconfig command.
To fix this problem, we simply just need to install the net-tools package.
What is ifconfig?
ifconfig is a system administration tool to configure the network interface configurations for the UNIX-like Operating system. It can show details information about the network interface in your Linux machine.
When you run this command, it will display the IP address, subnet mask, MAC address, and the default gateway for each network interface.
Uses of ifconfig
ifconfig is a very useful command. You are able to do many operations related to the network interface. some of them are:
- Display your network interface details, including IP address, subnet mask, MAC address, and more.
- Enable and disable a network interface.
- View the network settings of an Ethernet adapter.
- Change MAC address
- Assign an IP address to a network interface
These are some of ifconfig is capable of. The feature you will use often is the first one, displaying network interface details. Whether you want to look IP address or MAC address, you can simply run this command.
How to install ifconfig
To install ifconfig only requires you just a few commands. But before that, update your package repositories, and make sure it is all up to date.
sudo apt update
And then start the installation process by running the command below.
sudo apt install net-tools
The installation process should be already running now, and wait until the process is finished.
ifconfig command examples
Now that ifconfig is already installed on your machine, let’s learn how to use it by looking at our example.
ifconfig
Running the command without argument will give you some output similar to this
[linuxspin@ubuntu ~]$ 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 73682 bytes 4423616 (4.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 73682 bytes 4423616 (4.2 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:c5:cc:b9 txqueuelen 1000 (Ethernet)
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
wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.8.103 netmask 255.255.255.0 broadcast 192.168.8.255
inet6 fd44:d791:7ab8:1300:78df:1c69:69f9:c528 prefixlen 64 scopeid 0x0<global>
inet6 fe80::26c0:45b1:44f0:e7be prefixlen 64 scopeid 0x20<link>
ether 80:c5:f2:99:a0:a7 txqueuelen 1000 (Ethernet)
RX packets 4736886 bytes 5750493469 (5.3 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1785094 bytes 324503898 (309.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
It shows all of your network interface details. Those details covered some important data like IP address, MAC address, subnet mask, and many more.
ifconfig -a
With -a argument, it will show all of your network interfaces, including the disabled interface.
ifconfig [interface-name] down
With a down argument, you can disable your network interface, although when you restart your machine, the network interface will be re-enabled again.
ifconfig [interface-name] up
To enable some network interfaces you can use up argument.
ifconfig [inteface-name] 192.168.8.100
You can also assign an IP address to a network interface by adding an IP address argument after your network interface name.
Those are some of the example commands of ifconfig, if you want to see more details about it, you can look at the man page by using the command below
man ifconfig
How to uninstall ifconfig
to remove ifconfig from your machine, just run the command below
sudo apt remove net-tools
Conclusion
ifconfig is a powerful command to manage your network interface, you can change the IP address, and disable/enable the network interface with this command. I hope you learn a lot from this tutorial.