ifconfig: command not found
Nothing is broken. Since roughly 2018 most Linux distributions stopped installing the net-tools package that provides ifconfig, because the ip command replaced it. You can use the replacement immediately, or install the old tool in one command.
First, try the full path
On some systems ifconfig is installed but lives in /sbin or /usr/sbin, which is not on an ordinary user's PATH. Try:
/sbin/ifconfig
/usr/sbin/ifconfig
sudo ifconfig # sudo uses a PATH that includes sbinIf one of those works, the tool is present and you can add /sbin:/usr/sbin to your PATH in ~/.bashrc or just use ip.
The replacement: ip
These do what you were about to do with ifconfig:
ip -br addr # ifconfig (one line per interface)
ip addr # ifconfig -a (full detail)
ip addr show dev eth0 # ifconfig eth0
ip -s link # ifconfig (packet counters)
ip route # route -n
ip neigh # arp -n
sudo ip link set eth0 up # ifconfig eth0 up
sudo ip addr add 192.168.1.50/24 dev eth0 # ifconfig eth0 192.168.1.50 netmask 255.255.255.0$ ip -br addr
lo UNKNOWN 127.0.0.1/8 ::1/128
enp3s0 UP 192.168.1.42/24 fe80::a00:27ff:fe4e:66a1/64Also available almost everywhere: hostname -I prints every address on one line, and nmcli on desktops. The full ip reference →
Install net-tools
sudo apt update
sudo apt install net-toolssudo dnf install net-tools
# CentOS 7:
sudo yum install net-toolssudo pacman -S net-toolssudo zypper install net-tools-deprecated# BusyBox already provides ifconfig, route and arp
ifconfig
# for the full net-tools version:
sudo apk add net-toolssudo emerge sys-apps/net-toolsnix-shell -p nettools
# or add pkgs.nettools to environment.systemPackagesifconfig is part of the base system and cannot be missing. If your shell cannot find it, your PATH is broken: run /sbin/ifconfig and fix ~/.zshrc or ~/.profile.
Inside a Docker container
Container images are minimal and usually ship neither ifconfig nor ip. Options, from least to most intrusive:
# 1. ask Docker from the host
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' mycontainer
# 2. read /proc inside the container (works with no tools at all)
docker exec mycontainer cat /proc/net/fib_trie | grep -B1 '32 host' | grep -v host | awk '{print $2}' | sort -u
docker exec mycontainer cat /etc/hosts
# 3. use a debugging image that shares the container's network namespace
docker run --rm -it --network container:mycontainer nicolaka/netshoot ip -br addr
# 4. install tools inside (temporary; lost when the container is recreated)
docker exec -it mycontainer sh -c 'apt-get update && apt-get install -y iproute2' # Debian/Ubuntu images
docker exec -it mycontainer sh -c 'apk add --no-cache iproute2' # Alpine images
docker exec -it mycontainer sh -c 'microdnf install -y iproute' # UBI/RHEL imagesPrefer iproute2 over net-tools when you do install something; it is smaller and it is what every guide for the last decade assumes. Also note that Python, Node and Go images often have python3 -c "import socket; print(socket.gethostbyname(socket.gethostname()))" or equivalent available as a last resort.
WSL, Termux, ChromeOS, Git Bash
- WSL (Ubuntu): same as Ubuntu,
sudo apt install net-tools, or useip. You can also runipconfig.exeto see the Windows side. - Termux (Android):
pkg install net-tools;ipis available viapkg install iproute2. - ChromeOS Linux container: Debian;
sudo apt install net-tools. It shows the container's address, not the Chromebook's. - Git Bash / MSYS2 on Windows: there is no ifconfig and no ip. Use
ipconfig, which works from Git Bash because it is a Windows executable. - Cygwin:
ipconfigas above, or install thenet-tools-likecygwin ipis not available;netshand PowerShell work.
Why it was removed
net-tools was written for the Linux 1.x kernels and uses ioctl calls that cannot express multiple addresses per interface, policy routing, namespaces, VLANs or most things added to the kernel since 1999. iproute2 replaced it and distributions gradually dropped net-tools from the default install: Arch in 2011, RHEL 7 in 2014, Debian 10 and Ubuntu 18.04 in 2018. The package still exists and still works for basic tasks, but its output hides secondary addresses, which can mislead you when debugging. The longer explanation →