keepcalculator

06 Numbers and Powers

Ip Command Not Found? Fix It in 4 Steps

Card No. 06·65420 · Updated · Standard formula, shown below

If you see “ip command not found” on Linux, it usually means the ip utility (from the iproute2 package) isn’t installed or isn’t in your PATH. The fix is simple: install iproute2 with your package manager, or use the older ifconfig command as a temporary workaround.

What Is the ip Command?

The ip command is a modern Linux utility for managing network interfaces, routing, and tunnels. It’s part of the iproute2 package, which has been the default network tool on most Linux distributions since the early 2000s. It replaces older tools like ifconfig, route, and arp with a single unified interface.

Common uses include:

  • Viewing IP addresses: ip addr show
  • Bringing an interface up or down: ip link set eth0 up
  • Adding a route: ip route add default via 192.168.1.1
  • Showing ARP cache: ip neigh show

If the command isn’t found, you can’t manage your network from the terminal. That’s a problem for anyone configuring a server, troubleshooting connectivity, or setting up containers.

Why You Get “Command Not Found”

There are three common reasons:

  1. The package isn’t installed – Minimal installations (like Docker containers or stripped-down servers) often omit iproute2 to save space.
  2. The PATH is wrong – The ip binary lives in /usr/sbin/ip or /sbin/ip. If those directories aren’t in your PATH (common for non-root users), the shell can’t find it.
  3. You’re using a different OS – Some Unix-like systems (e.g., older Solaris) don’t ship ip at all. Even on Linux, BusyBox-based systems (like Alpine Linux) may use a simplified version.

To check if the binary exists but is just not in PATH, run:

ls -l /usr/sbin/ip /sbin/ip

If either exists, you can run it directly with the full path, or add the directory to your PATH.

How to Install iproute2 on Major Distros

Use your package manager. Here are the commands for common families:

  • Debian/Ubuntu: sudo apt install iproute2
  • RHEL/CentOS/Fedora: sudo dnf install iproute (or yum on older versions)
  • Arch Linux: sudo pacman -S iproute2
  • Alpine Linux: sudo apk add iproute2
  • openSUSE: sudo zypper install iproute2

After installation, verify with ip -V (shows version) or ip addr.

Quick Workarounds When You Can’t Install

If you’re on a restricted system (no root, no network, or a read-only filesystem), you can still manage networking with alternatives:

  • ifconfig – Older but still present on many systems. Shows interfaces and can assign addresses: sudo ifconfig eth0 192.168.1.10 netmask 255.255.255.0 up
  • route – For viewing and changing the routing table: sudo route add default gw 192.168.1.1
  • hostname -I – Quickly show all IP addresses assigned to the machine.
  • ping and traceroute – For basic connectivity testing.

These tools are part of the net-tools package on most distros. If you have neither ip nor ifconfig, you can also use busybox ip on embedded systems.

Common Mistakes and Misconceptions

One frequent error is typing ipconfig (Windows) instead of ip addr. On Linux, ipconfig doesn’t exist. Another is assuming ip is a shell built-in – it’s not; it’s an external program.

Also, if you’re in a container (Docker, LXC), the ip command may be missing even though the host has it. Containers often have minimal userlands. You can still inspect network settings from the host with docker exec or nsenter, but inside the container you may need to install the package.

Another misconception: ip and ifconfig output different formats. ip addr show gives you more detail (like MAC address, MTU, and flags) in a structured way. If you’re scripting, ip is more reliable because its output is stable across versions.

How to Fix PATH Issues

If the binary is installed but you still get “command not found”, your PATH is missing /usr/sbin or /sbin. To check your PATH:

echo $PATH

If those directories are missing, add them temporarily:

export PATH="$PATH:/usr/sbin:/sbin"

For a permanent fix, add that line to your ~/.bashrc or ~/.profile. On some systems, non-root users have a reduced PATH by design – using sudo ip addr might work because sudo often resets PATH to include sbin directories.

When to Use ip vs ifconfig

For modern Linux systems, always prefer ip. It’s actively maintained, supports advanced features like network namespaces and policy routing, and is the standard for scripting. ifconfig is deprecated on most distros but still available for compatibility.

If you’re writing a script that must run on both old and new systems, you can detect which command exists and fall back accordingly:

if command -v ip > /dev/null; then
    ip addr show
else
    ifconfig -a
fi

Frequently Asked Questions

Why does ip work with sudo but not without?

Because sudo typically resets the PATH to include /usr/sbin and /sbin, while your normal user PATH may not include them. The binary exists; your shell just can’t find it. Use the full path /usr/sbin/ip or add the directory to your PATH.

Is ip the same as ipconfig on Windows?

No. ipconfig is a Windows command that shows network configuration. ip is a Linux command that does much more – it can modify interfaces, routes, and tunnels, not just display them. The Linux equivalent of ipconfig is ip addr or ifconfig.

Can I use ip on macOS?

macOS doesn’t ship with ip by default. It uses ifconfig and netstat. You can install iproute2 via Homebrew (brew install iproute2mac), but the commands are slightly different. For most tasks, ifconfig is sufficient.

What does “RTNETLINK answers: Operation not permitted” mean?

That error appears when you try to change network settings without root privileges. ip needs CAP_NET_ADMIN capability. Use sudo or run as root. Viewing commands like ip addr show don’t require root, but modifying them does.

How do I check if iproute2 is installed?

Run which ip or command -v ip. If it returns a path like /usr/sbin/ip, it’s installed. You can also check the package manager: dpkg -l iproute2 on Debian/Ubuntu, rpm -q iproute on RHEL/Fedora.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →