LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 12-03-2008, 12:54 AM   #1
dangdtvn
LQ Newbie
 
Registered: Aug 2008
Location: Viet Nam
Distribution: OpenSource - RedHat
Posts: 10

Rep: Reputation: 0
Angry Why "-bash: ifconfig : command not found" when typing "$ifconfig"


i typed "$ifconfig" in the redhat 4. And it returned above error.other users, it does not matter at all. So someone can tell me the reason.


thanks!
 
Old 12-03-2008, 01:09 AM   #2
SqdnGuns
Member
 
Registered: Aug 2005
Location: Fountain Valley, CA / Thailand
Distribution: Slackware64 14.0
Posts: 981

Rep: Reputation: 88
Run as root, the command is "ifconfig"
 
Old 12-03-2008, 04:23 AM   #3
dangdtvn
LQ Newbie
 
Registered: Aug 2008
Location: Viet Nam
Distribution: OpenSource - RedHat
Posts: 10

Original Poster
Rep: Reputation: 0
Any reason else?
 
Old 12-03-2008, 04:41 AM   #4
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Linux Mint
Posts: 8,511

Rep: Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884Reputation: 884
Because ifconfig is locate in /sbin
sbin is not in the path from regular users, only in path from root.
you can execute the command by typing /sbin/ifconfig
 
Old 12-03-2008, 04:43 AM   #5
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,508

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Well, this happens only if you have a variable ifconfig whose value is ifconfig and you're not root, that is
Code:
$ ifconfig=ifconfig
$ $ifconfig
-bash: ifconfig: command not found
but I see no reason to launch a command as $variable, unless you have a script which dynamically set the name of the command and store it in a shell variable. Moreover, as already stated by SqdnGuns above, you have to be root to run ifconfig otherwise - as a regular user - it is not in your PATH.

Actually, you can run the ifconfig command as a regular user if you launch it with its absolute path:
Code:
$ /sbin/ifconfig
but only to display the ethernet interface settings, not to modify the settings themselves - for which you have to acquire root privileges. Please note that in my examples above the greyed $ sign is the command prompt.
 
Old 12-04-2008, 12:10 AM   #6
dangdtvn
LQ Newbie
 
Registered: Aug 2008
Location: Viet Nam
Distribution: OpenSource - RedHat
Posts: 10

Original Poster
Rep: Reputation: 0
Wink Thank everybody

I understood more about this issue!

thanks!
 
Old 09-20-2013, 04:05 AM   #7
sakibmas
LQ Newbie
 
Registered: Sep 2013
Posts: 2

Rep: Reputation: Disabled
Quote:
Originally Posted by repo View Post
Because ifconfig is locate in /sbin
sbin is not in the path from regular users, only in path from root.
you can execute the command by typing /sbin/ifconfig
sudo export PATH=/sbin:$PATH
 
Old 09-20-2013, 04:16 AM   #8
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
Quote:
Originally Posted by sakibmas View Post
sudo export PATH=/sbin:$PATH
no need for sudo
in fact, it won't work, since export is a bash builtin command
 
Old 09-20-2013, 05:51 AM   #9
sakibmas
LQ Newbie
 
Registered: Sep 2013
Posts: 2

Rep: Reputation: Disabled
Quote:
Originally Posted by Firerat View Post
no need for sudo
in fact, it won't work, since export is a bash builtin command

add this line in ~/bashrc file
export PATH=$PATH:/sbin
 
Old 09-20-2013, 06:01 AM   #10
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,471

Rep: Reputation: 444Reputation: 444Reputation: 444Reputation: 444Reputation: 444
~/.bashrc

but better to have it in ~/.profile
that way it is also available to other shells ( ksh, ash , csh and so on )
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
ifconfig "command not found" NNP Linux - Networking 2 11-17-2004 12:55 PM
problem using ifup and ifconfig "command not found" sicgixxer Linux - Networking 2 11-11-2004 09:39 PM
ifconfig "command not found"...? GDDYUP Linux - Networking 1 09-30-2001 01:10 AM


All times are GMT -5. The time now is 01:47 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration