If you run ifconfig and see “command not found,” it means the tool is not installed on your system or is not in your PATH. The fix is usually to install the correct package (net-tools on most Linux distributions) or to use the modern replacement ip command, which is preinstalled on nearly all current systems.
Why ifconfig Is Missing
ifconfig is part of the net-tools package, a collection of legacy networking utilities that includes route, arp, and netstat. Many modern Linux distributions no longer install net-tools by default because the iproute2 suite (which provides the ip command) has been the recommended tool for over a decade. Minimal server installs, containers, and cloud images often omit net-tools entirely to save space and reduce attack surface.
On macOS, ifconfig is present but its output differs from Linux, and some options are not available. On Windows, the equivalent command is ipconfig (note the extra “p”), but it is not the same tool.
How to Fix It on Linux
Install the net-tools package using your distribution’s package manager. The exact command depends on your distro:
- Debian / Ubuntu / Linux Mint:
sudo apt update && sudo apt install net-tools - RHEL / CentOS / Fedora:
sudo dnf install net-tools(older CentOS 7:sudo yum install net-tools) - Arch / Manjaro:
sudo pacman -S net-tools - openSUSE:
sudo zypper install net-tools
After installation, verify with ifconfig or ifconfig -a. You might need to log out and back in for the PATH to update, though usually it works immediately.
Use the ip Command Instead
The ip command from iproute2 is the modern replacement and is almost always preinstalled. It is more powerful and consistent across distributions. Common equivalents:
ifconfig→ip addrorip aifconfig -a→ip addr showifconfig eth0→ip addr show eth0ifconfig eth0 up→ip link set eth0 upifconfig eth0 down→ip link set eth0 downifconfig eth0 192.168.1.10 netmask 255.255.255.0→ip addr add 192.168.1.10/24 dev eth0
For a quick overview of all interfaces and their IP addresses, just run ip addr.
How to Check if ifconfig Is in Your PATH
Sometimes the command is installed but not found because the directory it lives in is not in your PATH. This is common on systems where /sbin or /usr/sbin is not included for regular users. To check, run:
which ifconfig– if it prints a path like/usr/sbin/ifconfig, the command exists but your shell cannot find it.echo $PATH– see if/sbinor/usr/sbinis listed.- If not, either use the full path (
/usr/sbin/ifconfig) or add it to your PATH for the current session:export PATH=$PATH:/usr/sbin.
On some systems, ifconfig is located in /bin instead. The fix is the same: ensure the directory is in your PATH.
Common Problems and Solutions
Here are frequent scenarios and their fixes:
- “ifconfig: command not found” after a fresh install: Install net-tools as shown above.
- Works with sudo but not as normal user: This usually means the binary is in
/sbinand that directory is not in your user’s PATH. Use the full path or add it to your PATH. - In a Docker container: Minimal images often lack net-tools. Install it with
aptorapk(Alpine) or useip addr. - In a script that calls ifconfig: Replace it with
ipcommands, or install net-tools as a dependency. - On macOS:
ifconfigexists but some Linux-specific flags (likewlan0) do not. Usenetworksetup -listallhardwareportsfor interface names.
ifconfig vs ip: Which Should You Use?
For most tasks, ip is the better choice. It is actively maintained, supports more features (like network namespaces and advanced routing), and its output is more consistent across distributions. However, ifconfig is still widely used in tutorials and older documentation, and many sysadmins are comfortable with it. If you are just checking an IP address, either works. For scripting and automation, prefer ip because it is more likely to be present and its output is easier to parse.
One notable difference: ifconfig shows only enabled interfaces by default, while ip addr shows all interfaces, including down ones. Use ifconfig -a to see all interfaces with ifconfig.
Frequently Asked Questions
Is ifconfig deprecated?
Yes, the net-tools package has been unmaintained for years, and most Linux distributions consider it deprecated. The iproute2 suite is the official replacement. However, ifconfig is still included in many distros for backward compatibility, and it still works fine for basic tasks.
Can I install ifconfig on Windows?
Windows does not use ifconfig. The equivalent is ipconfig. If you need Linux tools on Windows, you can use WSL (Windows Subsystem for Linux) and install net-tools there, or use a tool like Cygwin.
Why does my script fail with “ifconfig: not found” even though I installed it?
This usually happens when the script is run with a minimal PATH (e.g., from cron or a systemd service). The script cannot find the binary because /sbin is not in the PATH. Use the full path in the script or modify the environment.
How do I see my IP address without ifconfig?
Use ip addr (Linux) or ipconfig getifaddr en0 (macOS, where en0 is typically Wi-Fi). On Linux, you can also use hostname -I for a quick list of IP addresses.
What is the difference between ifconfig and ipconfig?
ifconfig is a Unix/Linux command for configuring network interfaces. ipconfig is a Windows command that displays and manages IP configuration. They are not related beyond both dealing with network settings.
Is it safe to install net-tools?
Yes, net-tools is a standard, well-known package available in official repositories. It is safe to install, though it is not actively developed. For production systems, consider using ip commands to avoid relying on deprecated tools.
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
- CentOS Stream for Developers: A Practical Guide
- Hide PHP Version HTTP Header: How To
- How to Replace a Game Controller Battery Safely
- Man-Sized 3D Printer? Why You Probably Don’t Need One100.0 cm³/h
- Scroll Horizontally with Mouse Wheel by Holding Shift5.00 min/km
- iPadOS 16 Supported Devices: Full List