This is part of my series, useful Linux commands and tips. The ifconfig (short for interface configurator), a system administration utility to configure, control, and query TCP/IP network interface parameters, is located in the system’s /sbin directory. /sbin is not usually included in the user’s PATH environment variable. For this reason, when you attempt to execute ifconfig, bash can not find it.
You have several options available to you.
- To execute it as root, use the full path
- Create a symbolic link to /sbin/ifconfig in your ~/bin directory or in /usr/bin. Both should be in your user’s PATH environment variable. If you put the link in /usr/bin, it will be available to all users on your system. If you put it in ~/bin, it will be available only to your user account.
- To create a symbolic link to /sbin/ifconfig, open a terminal window. Switch to your ~/bin directory
- xd ~/bin or to /usr/bin
- cd /usr/bin
- If you put the link in /usr/bin, you must su to root before creating the link. Create the symbolic link:
- ln –symbolic /sbin/ifconfig
- You can add /sbin to your user’s PATH environment variable. To do this, edit .bash_profile in your user’s directory. If there is no .bash_profile, then edit .bashrc. There should be a line similar to: PATH=$PATH:$HOME/bin
Edit the line to read: PATH=$PATH:$HOME/bin:/sbin
- Log out, then back in (no need to reboot). Now your bash command interpreter can locate any program in /sbin, and you can run them provided your user account has permission (authority) to do so.
Red Hat Enterprise Linux 5.0 – 5.4
CentOS 5.0 – 5.4