LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-08-2010, 01:12 PM   #1
ddennis
LQ Newbie
 
Registered: Mar 2010
Posts: 5

Rep: Reputation: 0
Ifconfig Broken


I am running centos 4.5
Kernel. 2.6.18

my ifconfig is broken. and i dont know how to fix it.
I go into /sbin and i see the file but when i try and execute the command is says bash: ifconfig: command not found.
The permissions on the file are as follows
-rwxr-xr-x 1 root root 71528 May 25 2008 ifconfig
i am still new to Linux and i don't know how to fix this. any suggestions on how to fix it would be great.
Thanks.
 
Old 04-08-2010, 01:22 PM   #2
troop
Member
 
Registered: Feb 2010
Distribution: gentoo, arch, fedora, freebsd
Posts: 379

Rep: Reputation: 96
# sudo vi /etc/profile.d/env.sh
add strings
Code:
PATH=/sbin:/usr/sbin/:$PATH
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
to end of file.
# . /etc/profile
# echo $PATH
 
Old 04-08-2010, 01:28 PM   #3
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,275

Rep: Reputation: 126Reputation: 126
Exactly how are you trying to execute "ifconfig"? It's probably a path problem, as "/sbin" isn't really supposed to be in your normal userid's path. Try typing this "sudo /sbin/ifconfig". If you don't have "sudo", then you need to become root and execute "/sbin/ifconfig".
 
Old 04-08-2010, 01:29 PM   #4
camorri
LQ Guru
 
Registered: Nov 2002
Location: Somewhere inside 9.9 million sq. km. Canada
Distribution: Slackware 14.1, 14.2
Posts: 5,090

Rep: Reputation: 483Reputation: 483Reputation: 483Reputation: 483Reputation: 483
It is probably not broken. 'Command Not Found' implies the command is not in your path. It is often not in a regular users path, but will be in the roots path.

To see what your path it set to, in a terminal type 'echo $PATH' without the quotes, just what is between them. As a regular user I get this -

Quote:
$ echo $PATH
/usr/bin:/bin:/usr/local/bin:/usr/X11R6/bin/:/usr/games:/usr/lib/qt4/bin:/home/cliff/bin:/sbin
Each entry is where the system will look when I type a command. If it is found, it does it. If not, then it will return 'command not found'.

Here is the path for root on my system -
Quote:
# echo $PATH
/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin:/usr/lib/qt4/bin
If you compare the two, they are different. Now, where is ifconfig? To answer that I run the command 'locate ifconfig' and the system returns
Quote:
locate ifconfig
/sbin/ifconfig
.

So you can see ifconfig will be found by root, but not by ther regular user. However, if I want to run it as a regular user, all I need to do is add the path to the command. Like this...

Quote:
$ /sbin/ifconfig
eth0 Link encap:Ethernet HWaddr 00:1D:7D:20:F4:67
inet addr:192.168.1.26 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:171340 errors:0 dropped:0 overruns:0 frame:0
TX packets:143638 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:110034071 (104.9 MiB) TX bytes:13167384 (12.5 MiB)
Interrupt:24 Base address:0xc000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:14351 errors:0 dropped:0 overruns:0 frame:0
TX packets:14351 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:794028 (775.4 KiB) TX bytes:794028 (775.4 KiB)
and the command runs.

Hope this helps...
 
Old 04-08-2010, 03:25 PM   #5
ddennis
LQ Newbie
 
Registered: Mar 2010
Posts: 5

Original Poster
Rep: Reputation: 0
Thank you all for your quick replys

This is my users $PATH
echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/ddennis/bin


this is my Root $path
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin


if i do a /sbin/ifconfig it does work.
so I can tell this is entirely a path issue.
As per the first reply i tried to edit the file they listed to add /sbin to the path but the file at the location /etc/profile.d/env.sh does not exist. what file do i need to edit to add the /sbin to my user accounts?
 
Old 04-08-2010, 03:34 PM   #6
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,275

Rep: Reputation: 126Reputation: 126
You should really not add /sbin to your user accounts.
 
Old 04-08-2010, 04:53 PM   #7
nuwen52
Member
 
Registered: Feb 2009
Distribution: Debian, CentOS 5, Gentoo, FreeBSD, Fedora, Mint, Slackware64
Posts: 208

Rep: Reputation: 46
Quote:
You should really not add /sbin to your user accounts.
Generally, I agree, and it doesn't take much to just simply type /sbin/ifconfig if you need it. But, if you really want to add it to the path (and assuming you use bash, which it the standard for CentOS I think), you just add:
Code:
PATH="$PATH:/sbin"
to your ~/.bashrc file. If you don't have one, just create it. Mine looks like:
Code:
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific aliases and functions
alias ]='gnome-open'

Last edited by nuwen52; 04-08-2010 at 04:56 PM.
 
Old 04-08-2010, 05:21 PM   #8
ddennis
LQ Newbie
 
Registered: Mar 2010
Posts: 5

Original Poster
Rep: Reputation: 0
the reason i am wanting to add it to a specific to user is because I am getting e-mail notification from a cron job that is saying the ifconfig command is not found. the cron job is coming specifically from a file called collectinfo.pl. so i am trying to figure out how to get this to stop because the cron job runs every 5 min. and every time it failes i am getting a e-mail saying that the cron job had errors.
 
Old 04-08-2010, 05:30 PM   #9
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,275

Rep: Reputation: 126Reputation: 126
Simple, fix the cron job and have it execute "/sbin/ifconfig" rather than just "ifconfig". Generally, any script executing a program should use the whole path, not just the program's name. That should be one of the first thing a script-writer learns.
 
Old 04-09-2010, 12:46 PM   #10
ddennis
LQ Newbie
 
Registered: Mar 2010
Posts: 5

Original Poster
Rep: Reputation: 0
removed. because of double post

Last edited by ddennis; 04-09-2010 at 12:51 PM.
 
Old 04-09-2010, 12:50 PM   #11
ddennis
LQ Newbie
 
Registered: Mar 2010
Posts: 5

Original Poster
Rep: Reputation: 0
the cron job is not actually running the ifconfig command it is running a command for a file called collectinfo.pl. I believe that the collectinfo.pl in its processing is running the ifonfig command. and if there is a way to edit that .pl file I would prefer that. but i dont know if that possible.

Last edited by ddennis; 04-09-2010 at 12:53 PM.
 
Old 04-09-2010, 12:52 PM   #12
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,275

Rep: Reputation: 126Reputation: 126
"collectinfo.pl" is a perl file. It can be edited just like any other text file. Give it a shot. Make a backup first, of course.
 
  


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
Why "-bash: ifconfig : command not found" when typing "$ifconfig" dangdtvn Linux - Server 9 09-20-2013 07:01 AM
ifconfig rust8y Solaris / OpenSolaris 5 07-25-2006 08:54 AM
connecting /sbin/ifconfig to bash command ifconfig flammable2 Fedora 4 11-12-2005 08:58 AM
ifconfig usb0 produces "Broken pipe" JohnKFT Slackware 0 11-13-2004 05:56 PM
ifconfig dexter_modem Linux - Networking 3 02-20-2003 01:02 PM


All times are GMT -5. The time now is 10:46 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration