Troubleshooting: ifconfig Not Found in Debian

I’ve actually written about ifconfig not found before, but noticed recently another possible scenario so will mention it today.

Make Sure Net-Tools Package is Installed

This is still the most common reason for your shell not finding the ifconfig command: it’s just not installed by default. So install it using apt command:

$ apt install net-tools

Call ifconfig Using Full Path

This is the thing I noticed on my Debian VM earlier today: your regular user may not have /sbin directory in its PATH. Which means ifconfig command will still not work if you just type the command name:

greys@debian9:~$ ifconfig
-bash: ifconfig: command not found
You have new mail in /var/mail/greys

But if you type the full path to the command, it will work:

greys@debian9:~$ /sbin/ifconfig
enp0s3: flags=4163 mtu 1500
inet 192.168.1.XX netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::a00:27ff:febe:8a41 prefixlen 64 scopeid 0x20
ether 08:00:27:be:8a:41 txqueuelen 1000 (Ethernet)
RX packets 26263716 bytes 9251567381 (8.6 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 131362 bytes 12206621 (11.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Update PATH Variable to Include /sbin

Edit the .profile file in your home directory. For me it’s /home/greys/.profile.

Somewhere towards the end of it there should be a PATH variable updates section, on my VM it includes linuxbrew that I installed recently:

set PATH so it includes user's private bin if it exists

if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi

PATH=$PATH:/home/greys/.linuxbrew/bin
eval $(/home/greys/.linuxbrew/bin/brew shellenv)

We need to update this section. And if there isn’t one, just create another one at the end of the file. Both changes should aim to add /sbin directory to the PATH variable.

Update the file:

PATH=$PATH:/home/greys/.linuxbrew/bin

… with this:

PATH=$PATH:/home/greys/.linuxbrew/bin:/sbin

… or create new one:

PATH=$PATH:/sbin

Save the file and read it again to test:

greys@debian9:~$ source .profile
/home/greys/.linuxbrew/Homebrew/Library/Homebrew/brew.sh: line 4: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8): No such file or directory

That’s it, type ifconfig and it should work now:

greys@debian9:~$ ifconfig
enp0s3: flags=4163 mtu 1500
inet 192.168.1.XX netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::a00:27ff:febe:8a41 prefixlen 64 scopeid 0x20
ether 08:00:27:be:8a:41 txqueuelen 1000 (Ethernet)
RX packets 26267641 bytes 9252896750 (8.6 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 131600 bytes 12231427 (11.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

See Also

  • Debian 10 Buster
  • ifconfig command
  • ifconfig command not found
  • Upgrading Raspberry Pi to Raspbian OS based on Debian Buster



Contact Me

Follow me on Facebook, Twitter or Telegram:
Recommended
I learn with Educative: Educative
IT Consultancy
I'm a principal consultant with Tech Stack Solutions. I help with cloud architectrure, AWS deployments and automated management of Unix/Linux infrastructure. Get in touch!
Recent Articles
03 Sep 2024

macOS Sequoia 15.0

02 Sep 2024

Video: Has This Worked Before?

24 Mar 2024

Homelab: Mac Pro 2013 32GB

Recent Tweets