ipconfig.co.uk

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:

Linux · Terminal
/sbin/ifconfig
/usr/sbin/ifconfig
sudo ifconfig          # sudo uses a PATH that includes sbin

If 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:

Linux · Terminal
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
Output
$ ip -br addr
lo               UNKNOWN        127.0.0.1/8 ::1/128
enp3s0           UP             192.168.1.42/24 fe80::a00:27ff:fe4e:66a1/64

Also available almost everywhere: hostname -I prints every address on one line, and nmcli on desktops. The full ip reference →

Install net-tools

Linux · Terminal
sudo apt update
sudo apt install net-tools

Inside a Docker container

Container images are minimal and usually ship neither ifconfig nor ip. Options, from least to most intrusive:

Linux · Terminal
# 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 images

Prefer 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 use ip. You can also run ipconfig.exe to see the Windows side.
  • Termux (Android): pkg install net-tools; ip is available via pkg 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: ipconfig as above, or install the net-tools-like cygwin ip is not available; netsh and 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 →

Related pages

Last reviewed . Command syntax verified against Windows 11, Ubuntu 24.04, macOS 15 and FreeBSD 14 unless noted otherwise.

Spotted a mistake or a switch we have missed? Every page on this site is written to be checked against real output, so please test on your own machine and compare.