[SOLVED] Command 'ifconfig' is available in '/sbin/ifconfig'

Questions about applications and software
Forum rules
Before you post please read how to get help

[SOLVED] Command 'ifconfig' is available in '/sbin/ifconfig'

Postby WhatUsernameIsFree? on Wed Nov 30, 2011 3:03 am

Hi, when I try type ifconfig I get:
Code: Select all
Command 'ifconfig' is available in '/sbin/ifconfig'
The command could not be located because '/sbin' is not included in the PATH environment variable.
This is most likely caused by the lack of administrative priviledges associated with your user account.
ifconfig: command not found


Apparently the solution is related to adding /sbin/ to my echo $PATH which shows
Code: Select all
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

I cannot 'nano $PATH', so how can I edit my $PATH?

Thank you :)
Last edited by WhatUsernameIsFree? on Sun Dec 04, 2011 4:50 am, edited 1 time in total.
WhatUsernameIsFree?
Level 4
Level 4
 
Posts: 216
Joined: Wed Oct 19, 2011 1:32 pm

Linux Mint is funded by ads and donations.
 

Re: LMDE: Command 'ifconfig' is available in '/sbin/ifconfig

Postby Oscar799 on Wed Nov 30, 2011 11:39 am

Moved here from the main forum
Image
"Don't fix it if it ain't broken,don't break it if you can't fix it" Husse
Registered Linux User #511789
User avatar
Oscar799
Level 18
Level 18
 
Posts: 8970
Joined: Tue Aug 11, 2009 9:21 am
Location: United Kingdom

Re: LMDE: Command 'ifconfig' is available in '/sbin/ifconfig

Postby doktordave on Wed Nov 30, 2011 12:41 pm

WhatUsernameIsFree?,

Try this instead:
Code: Select all
sudo ifconfig
User avatar
doktordave
Level 2
Level 2
 
Posts: 60
Joined: Wed Apr 08, 2009 8:57 am
Location: Danville, VA

Re: LMDE: Command 'ifconfig' is available in '/sbin/ifconfig

Postby WhatUsernameIsFree? on Wed Nov 30, 2011 2:38 pm

Thanks for moving to a more appropriate section. :)

sudo ifconfig works, is that expected behaviour? I ask as typing in '/sbin/ifconfig' works too. Surely if it was expected behaviour I should get an error relating to needing sudo when I type 'ifconfig'

I've exactly the same problem with 'powertop', but that *does* require sudo and displays this message if I type /usr/sbin/powertop
Code: Select all
PowerTOP 1.97 beta 1 must be run with root privileges.
exiting...


Thanks
WhatUsernameIsFree?
Level 4
Level 4
 
Posts: 216
Joined: Wed Oct 19, 2011 1:32 pm

Re: LMDE: Command 'ifconfig' is available in '/sbin/ifconfig

Postby Anakinholland on Wed Nov 30, 2011 3:17 pm

WhatUsernameIsFree? wrote:sudo ifconfig works, is that expected behaviour? I ask as typing in '/sbin/ifconfig' works too. Surely if it was expected behaviour I should get an error relating to needing sudo when I type 'ifconfig'


Hya, 2 different things mate, one requires root to run, other doesn't know where to find the executable.

$PATH is a shell-variable, not a file, so an editor is useless as you already noticed :) It is filled when you log on to the system, and you can change it like this:

Code: Select all
vi ~/.profile

or

Code: Select all
gedit ~/.profile

~/ is short-hand for your home-directory. If you view your home-directory you will most likely not see it immediately, as the . (period) in front of the file makes it hidden. It will show up using "ls" if you add the parameter "-a", or in your filebrowser when you press Ctrl+H (assuming it is Nautilus).

Anyway, in the last part of the file you will see something like this bit:

Code: Select all
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

Change

Code: Select all
PATH="$HOME/bin:$PATH"

to

Code: Select all
PATH="$HOME/bin:/sbin:$PATH"

Then log out and back in.

The reason why this does work for sudo is most likely that user root does have /sbin in $PATH, but my test doesn't quite prove that.

If I run the next commands i may become clear:

Code: Select all
anakin@stormbird ~ $ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
anakin@stormbird ~ $ PATH=$PATH:/test
anakin@stormbird ~ $ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/test
anakin@stormbird ~ $ sudo echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/test
anakin@stormbird ~ $ sudo su -
stormbird ~ # echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Personally I didn't expect to be any difference between sudo and actually being root. As you can see, a regular "echo" and "sudo echo" have identical output, but clearly on your system it would not, else ifconfig would have worked for you!?

Maybe someone else can explain that, at least you'll have a work-around for now :)

Regards,

Anakin
Please Edit your initial post title and add [SOLVED] once your question is resolved.
User avatar
Anakinholland
Level 3
Level 3
 
Posts: 145
Joined: Sun Oct 30, 2011 8:09 am

Re: LMDE: Command 'ifconfig' is available in '/sbin/ifconfig

Postby WhatUsernameIsFree? on Fri Dec 02, 2011 6:34 pm

Thanks for you help.

Would be interested to hear the answer as to why sudo echo $PATH and echo $PATH as root come up with different things. :)
WhatUsernameIsFree?
Level 4
Level 4
 
Posts: 216
Joined: Wed Oct 19, 2011 1:32 pm

Re: LMDE: Command 'ifconfig' is available in '/sbin/ifconfig

Postby xircon on Sat Dec 03, 2011 5:32 pm

Because different users can have different paths. Sudo elevates the command to use root privileges, whilst staying as the same user.

Proof:
Code: Select all
sudo echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/sbin <<<< USER
molly2@n5010 ~ $
molly2@n5010 ~ $ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/sbin <<<< USER
molly2@n5010 ~ $ su
Password:
n5010 molly2 # echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin <<<< ROOT
n5010 molly2 #
Dell Inspiron N5010 / Core I5 / ATI Mobility Radeon HD5400, LMDE Tracking Sid & Cinnamon Desktop
"Ubuntu is an African word meaning 'I can't configure Debian'"
User avatar
xircon
Level 5
Level 5
 
Posts: 775
Joined: Sun Aug 01, 2010 7:59 am
Location: Sheffield, UK

Re: LMDE: Command 'ifconfig' is available in '/sbin/ifconfig

Postby WhatUsernameIsFree? on Sun Dec 04, 2011 4:35 am

xircon wrote:Because different users can have different paths. Sudo elevates the command to use root privileges, whilst staying as the same user.


Hi,

Thanks, for me that certainly explains the differences, as well as the difference between suing to root and sudo :)

Love this forum, when you ask 'silly' questions you're not treated like an idiot! :)
WhatUsernameIsFree?
Level 4
Level 4
 
Posts: 216
Joined: Wed Oct 19, 2011 1:32 pm

Re: LMDE: Command 'ifconfig' is available in '/sbin/ifconfig

Postby xircon on Sun Dec 04, 2011 4:53 am

I know, nice people with a helpful attitude & good sense of humour, I came from Mandriva and knew sod all about apt, so had lots of basic questions. Can't even remember simple urpmi commands now :)
Dell Inspiron N5010 / Core I5 / ATI Mobility Radeon HD5400, LMDE Tracking Sid & Cinnamon Desktop
"Ubuntu is an African word meaning 'I can't configure Debian'"
User avatar
xircon
Level 5
Level 5
 
Posts: 775
Joined: Sun Aug 01, 2010 7:59 am
Location: Sheffield, UK

Re: [SOLVED] Command 'ifconfig' is available in '/sbin/ifcon

Postby nukeqler on Fri Feb 17, 2012 12:46 am

The reason that
Code: Select all
sudo echo $PATH
is the same as
Code: Select all
echo $PATH
is that in both cases the shell expands the variable before running the command line, so the actual arguments that sudo gets are 'echo /bin:/usr/sbin'.
nukeqler
Level 1
Level 1
 
Posts: 1
Joined: Fri Feb 17, 2012 12:40 am

Linux Mint is funded by ads and donations.
 

Return to Software & Applications

Who is online

Users browsing this forum: No registered users and 2 guests