The “ip” command is a Linux command used to configure and manage network interfaces on a Linux system.
It can be used to set various network interface parameters, such as IP addresses, netmasks, and gateway addresses.
It can also be used to display information about the current network configuration, including IP addresses, netmasks, and the status of network interfaces.
The command syntax is “ip [OPTIONS] OBJECT [COMMAND] [ARGS]”.
Get Your Free Linux training!
Join our free Linux training and discover the power of open-source technology. Enhance your skills and boost your career! Learn Linux for Free!Some examples of using the “ip” command include “ip addr show” to show the current IP addresses assigned to network interfaces, and “ip route show” to display the routing table.
However, many users seem to have issues running the ip command in their Linux machines, and have faced the following error message:
$ ip: command not found
Table of Contents
Install ip command on Linux
The message “ip: command not found” indicates that the “ip” command is not installed on the system or it’s not in the system’s PATH.
The “ip” command is part of the “iproute2” package, which is usually pre-installed on most Linux distributions.
If not, you can install the ‘iproute2’ package which includes ‘ip’ command.
If you are using Ubuntu or Debian, you can install the package by running the command:
sudo apt-get install iproute2
If you are using Centos or Redhat:
sudo yum install iproute
If you are using Fedora:
sudo dnf install iproute
MacOS (using Homebrew)
$ brew update
$ brew install iproute2mac
Run ip command with full path on Linux
If you are running a version of Linux that does include the “ip” command, but you are still getting the “command not found” error, it’s likely that the command is not in the system’s PATH.
You can try running the command with the full path, for example, ‘/sbin/ip addr show’
The full path of a command is the complete file system directory path that leads to the command’s executable file.
It is used to specify the exact location of the command when executing it in a terminal or command prompt.
For example, on a Linux system, the full path of the “ls” command might be “/bin/ls” and on a Windows system, the full path of the “cmd” command might be “C:\Windows\System32\cmd.exe”.
In our case, the full path of the “ip” command can be run in a terminal or command prompt in order to execute the command.
On a Linux system, the full path of the “ip” command is typically “/sbin/ip” or “/usr/sbin/ip”.
- Open a terminal window or command prompt.
- Use the “which” or “where” command (on Linux or Windows respectively) to find the full path of the “ip” command. For example, on Linux you would type “which ip”
- Copy the full path of the command that was returned by the command.
- Type the full path of the command followed by any arguments or options you want to use. For example, if the full path of the “ip” command is “/sbin/ip” you would type “/sbin/ip addr show” to display all the IP addresses of all interfaces.
Alternatively, you can also use the find command if you are not sure about the path of ip command.
For example, in Linux you would type “find / -name ip” and it will search the entire file system and show you the path of the ip command if it exists.
By using the full path of the command, you are specifying the exact location of the command to the system, which ensures that the correct version of the command is run, even if there are multiple versions of the command available on the system.
add ip command full path to the PATH environment variable
To add the full path of the “ip” command to the PATH environment variable, you will need to edit your system’s environment variables. The process for doing this can vary depending on the operating system you are using.
On Linux:
- Open a terminal window.
- Type “nano ~/.bashrc” and press Enter. This will open the .bashrc file in the nano text editor.
- Scroll to the bottom of the file and add the path to the “ip” command. For example, if the “ip” command is located in the “/sbin” directory, you would add the following line: “export PATH=$PATH:/sbin”
- Press “Ctrl + X” to exit the editor, then press “Y” to save the changes.
- Type “source ~/.bashrc” to apply the changes to your current session.
After adding the path to the “ip” command to the PATH environment variable, you should be able to run the “ip” command by simply typing its name in the terminal or command prompt, without specifying the full path.
ip command alternative
The “ip” command is a command-line utility for Linux and other Unix-like operating systems that provides advanced network configuration and troubleshooting capabilities.
There are several alternatives to the “ip” command that provide similar functionality:
- “ifconfig” : This is one of the most commonly used alternatives to the “ip” command. It is typically used to configure network interfaces and view their status.
- “route” : This command is used to view and manipulate the IP routing table. It can be used to view the current routing table, add or remove routes, and change the default gateway.
- “netstat” : This command is used to display network statistics, including active connections and routing information.
- “ss” : This command is similar to netstat, it displays socket statistics, including information on open ports and active connections.
On Windows, you can use “ipconfig” command which is an alternative to “ip” command. It’s used to view and troubleshoot IP addresses and configurations on a Windows computer.