ifconfig command not found ?

Hi,

Using DietPi 146 on RPI3 i’ve successfully set my PI to STATIC IP (vs DHCP)
Everything OK, my PI is correctly networked.

However i get ifconfig “command not found” messages when i launch LXterminal and current IP is not displayed.

/DietPi/dietpi/func/obtain_network_details: line 48: ifconfig: command not found
/DietPi/dietpi/func/obtain_network_details: line 83: ifconfig: command not found
 IP Address |

Also my current IP and Mask, not displayed on Dietpi-config - Ethernet Network Options - Current details
What’s the problem with ifconfig ?

Thank you.

Hi,

It may be that you’ve accidentally/inadvertently removed the net-tools package (which contains ifconfig, and is required for dietpi-config to scrape network settings correctly) from the system.

Please run the following to reinstall:

apt-get install net-tools

Thank you @Fourdee,
ifconfig seems already installed, however look like as an env path issue.

ifconfig OK if launched from /sbin/ifconfig command.
How to set /sbin in the env path ?

Any idea on how to fix my ifconfig path issue ?
Thank’s



export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Thank you @Fourdee but where to set the export PATH to get a persistent fix:
In root .bashrc ?
in etc/profile ?

ifconfig is called from /DietPi/dietpi/func/obtain_network_details

Yep, PATH entry will exist on a fresh install, so not sure what the cause is, but yes its in /etc/profile:

From Odroid C2 /etc/profile (Should be same for all on Jessie):

/etc/profile# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "`id -u`" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
export PATH

if [ "$PS1" ]; then
  if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
    # The file bash.bashrc already sets the default PS1.
    # PS1='\h:\w\$ '
    if [ -f /etc/bash.bashrc ]; then
      . /etc/bash.bashrc
    fi
  else
    if [ "`id -u`" -eq 0 ]; then
      PS1='# '
    else
      PS1='$ '
    fi
  fi
fi

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi

My v146 RPI3 /etc/profile seems OK (quoted later).
So something else broke the PATH.

I’ve only installed (from the menus and as root user) Roonbridge, networkaudiod, and XRDP.
No manual edits and everything running perfectly (out of ifconfig path).

root@DietPi:~# more /etc/profile

/etc/profile: system-wide .profile file for the Bourne shell (sh(1))

and Bourne compatible shells (bash(1), ksh(1), ash(1), …).

if [ “id -u” -eq 0 ]; then
PATH=“/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”
else
PATH=“/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games”
fi
export PATH

if [ “$PS1” ]; then
if [ “$BASH” ] && [ “$BASH” != “/bin/sh” ]; then

The file bash.bashrc already sets the default PS1.

PS1='\h:\w$ ’

if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ “id -u” -eq 0 ]; then
PS1=‘# ’
else
PS1=’$ ’
fi
fi
fi

if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi


We do see similar issues due to filesystem corruptions. I actually pulled the plug on RPi 3 with Raspbian lite the other day, rebooted, ls/df command not found.

I believe the issues you are experiencing are due to filesystem corruptions. The only way to prevent it:

Either way, i’d highly recommend writing a new image as you may have further issues, related to filesystem corruption, further down the line.

Thank you @Fourdee.
I’m not sure about your “filesystem corruption” diagnostic because when i’m running ifconfig command from OSX terminal, PATH is OK (ssh as root).

OK
Terminal.png
The PATH issue arise when ifconfig command is run from LXterminal via RDP Microsoft Remote Desktop (as root too).
In this case /usr/sbin is not in the PATH replaced by /usr/X11R6/bin ?

KO

Try forcing linux terminal emulation.

Add following to end of /root/.bashrc

export TERM='linux'

reload:

. /root/.bashrc

Thank you @Fourdee,
I’ve already set TERM=linux in .bashrc according to your recommendation, see this thread: https://dietpi.com/forum/t/xterm-16color-unknown-terminal-type/1108/1

No joy …
PATH KO from LXterminal via RDP and PATH OK when from OSX terminal.
Seems PATH is set differently when i’m logging from RDP (Microsoft Remote Desktop).
/usr/sbin is not in the PATH replaced by /usr/X11R6/bin

For example, same issue when running other command from LXterminal via RDP:

root@DietPi:~# reboot
root@DietPi:~# bash: reboot: command not found

Everything else is running perfectly …
Any idea ?

I suggest closing this thread pointing to a more recent one, like https://dietpi.com/forum/t/network-status/3793/2

well you pulled up a 3 years old thread. Basically it was closed already. :rofl: