ifconfig error showing invalid errors for ifconfig en0 | grep ether

Whenever I run ifconfig en0 | grep ether it gives me "ifconfig: invalid arguments".

Later I found out that there is something wrong with my ifconfig command and it's not the original one. The man page of ifconfig says GNU inetutils 1.9.3-dirty at the end.

How do I get back the original one?


Solution 1:

The which command will show what path a command is running:

me@dev ~ % which ifconfig
/sbin/ifconfig

So, you see on my dev machine, the standard path to the program. You could run fully qualified paths to get the default macos versions of these tools and be “most canonical” no matter which other versions are installed:

/sbin/ifconfig en0 | /usr/bin/grep ether

Solution 2:

You probably installed inetutils 1.9.3 with a package manager like brew or MacPorts.

Besides GNU versions of various tools (telnet, rsh etc.) it also installs a GNU version of ifconfig.

To distinguish the GNU tools from macOS tools with the same names they are usually linked from the install dir (installed with brew this is: /usr/local/opt/inetutils/gnubin) to a directory in the standard PATH prefixed with a g (e.g. ifconfig > gifconfig or ftp > gftp).

If you add this install dir to your PATH variable in a way that gives preference over the standard paths, the GNU tools will be executed instead of the original ones.


Check your PATH variable: echo $PATH. You will likely see something like:

/usr/local/opt/inetutils/gnubin:/usr/local/bin:/usr/bin:/bin:...

Now edit the file which determines your PATH variable (probably either ~/.bashrc or ~/.bash_profile) and remove the gnubin path.

Example: nano ./bash_profile

...
export PATH="/usr/local/opt/inetutils/gnubin:/usr/local/mysql/bin:$PATH"
...

Change this to:

...
export PATH="/usr/local/mysql/bin:$PATH"
...

Then close the Terminal window or relaunch Terminal.app. This will "reenable" the standard versions of the commands. The GNU tools are still available by entering a command prefixed with a g (e.g. gifconfig or gftp).