ifconfig command not found ?

Having issues with your DietPi installation, or, found a bug? Post it here.
volpone
Posts: 21
Joined: Fri Mar 17, 2017 1:38 pm

ifconfig command not found ?

Post by volpone »

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.

Code: Select all

/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.
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: ifconfig command not found ?

Post by Fourdee »

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:

Code: Select all

apt-get install net-tools
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
volpone
Posts: 21
Joined: Fri Mar 17, 2017 1:38 pm

Re: ifconfig command not found ?

Post by volpone »

Fourdee wrote: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:

Code: Select all

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 ?
volpone
Posts: 21
Joined: Fri Mar 17, 2017 1:38 pm

Re: ifconfig command not found ?

Post by volpone »

Any idea on how to fix my ifconfig path issue ?
Thank's
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: ifconfig command not found ?

Post by Fourdee »

volpone wrote:Any idea on how to fix my ifconfig path issue ?
Thank's

Code: Select all

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
volpone
Posts: 21
Joined: Fri Mar 17, 2017 1:38 pm

Re: ifconfig command not found ?

Post by volpone »

Fourdee wrote:
volpone wrote:Any idea on how to fix my ifconfig path issue ?
Thank's

Code: Select all

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
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: ifconfig command not found ?

Post by Fourdee »

volpone wrote: in etc/profile ?
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):

Code: Select all

/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
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
volpone
Posts: 21
Joined: Fri Mar 17, 2017 1:38 pm

Re: ifconfig command not found ?

Post by volpone »

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
Fourdee wrote:
volpone wrote: in etc/profile ?
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):

Code: Select all

/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
User avatar
Fourdee
Site Admin
Posts: 2788
Joined: Tue Feb 06, 2007 1:36 pm

Re: ifconfig command not found ?

Post by Fourdee »

volpone wrote:My v146 RPI3 /etc/profile seems OK (quoted later).
So something else broke the PATH.
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:
- Use a stable PSU (eg: official RPi 5v/2.5A)
- Use a stable SD card (eg: Sandisk), and, ideally, run a full format on the card prior to writing image (refresh/reset all cells): https://github.com/Fourdee/DietPi/issue ... -283030267
- Avoid power cuts

Either way, i'd highly recommend writing a new image as you may have further issues, related to filesystem corruption, further down the line.
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
volpone
Posts: 21
Joined: Fri Mar 17, 2017 1:38 pm

Re: ifconfig command not found ?

Post by volpone »

Fourdee wrote:
volpone wrote:My v146 RPI3 /etc/profile seems OK (quoted later).
So something else broke the PATH.
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:
- Use a stable PSU (eg: official RPi 5v/2.5A)
- Use a stable SD card (eg: Sandisk), and, ideally, run a full format on the card prior to writing image (refresh/reset all cells)
- Avoid power cuts
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
RDP_ifconfig.png
Post Reply