PDA

View Full Version : Ifconfig not working


RichGags
2006-01-24, 10:10 AM CST
Hi sorry about this, I must be an idiot or something. Ive read all the ifconfig posts, yes there are hundreds of them...But its just not working for me.

I see it there. Its in /sbin.

When I type whereis ifconfig, I get this:

ifconfig: /sbin/ifconfig /usr/share/man/man8/ifconfig.8.gz

So, I switch to root, even tryed su -, go to sbin, do a "dir" just to make sure its there...ITS THERE...but everytime I type ifconfig, I get:

bash: ifconfig: command not found

What am I doing wrong?

Thanks!
Rich

giulix
2006-01-24, 10:16 AM CST
Check that /sbin is in root's path

su -
echo $PATH

If not, add it to /etc/profile

...

# Path manipulation
if [ $EUID = 0 ]; then
pathmunge /sbin
pathmunge /usr/sbin
pathmunge /usr/local/sbin
fi

...

RichGags
2006-01-24, 10:18 AM CST
Its working now. Thank you!

RichGags
2006-01-24, 10:18 AM CST
But do you have to be root to run ifconfig?

giulix
2006-01-24, 10:24 AM CST
Nope, if all you want to do is check your NICs configuration. Since /sbin is made available to root's $PATH only, you need to specify its absolute path when invoking it from another user's shell. Or you could add /sbin to all users' $PATHs, but that would be improper...

RichGags
2006-01-24, 10:35 AM CST
How would I add /sbin to my user's $PATH?

giulix
2006-01-24, 10:43 AM CST
That's the wrong question: The right question would be: "Why is it improper" ? :D

Anyway:
.bashrc

export PATH=$PATH:/sbin

.cshrc

setenv PATH "$PATH":/sbin

Dayguy
2006-01-24, 01:06 PM CST
Since RichGags didn't ask, I will...why is it improper to add /sbin to all user's PATH variable?

giulix
2006-01-24, 01:31 PM CST
Because, historically, /sbin has always contained system administration commands not intended for "normal" users. Nowadays the distinction between sys admins and users, especially on Linux desktop systems, has become less important but there are lots of places where it still makes perfect sense.

Dayguy
2006-01-24, 01:45 PM CST
Thanks for the reply. I'll fix this when I get home (I'm stuck at work on Windoze). Do you recommend editing the .bashrc file or would the safest bet be to add /sbin/ prior to whatever command needs it? I apologize for all the questions. I've only just recently changed my XP/FC4 dual boot into 100% pure Fedora Core 4, and I want to learn as much as I possibly can. I've been lost in Windows for so long that I've forgotten how to learn.

Thanks again for your help.

RichGags
2006-01-24, 02:30 PM CST
Cool. Since Im the only one who uses the machine its ok for the user to have root privleges.

One question though....

My .bashrc looks like this:

# .bashrc

# User specific aliases and functions

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

What should I make it look like?

Also, I could not find .cshrc

Where is that?

giulix
2006-01-25, 02:19 AM CST
My suggestion is that you DON'T modify you .bashrc but prepend /sbin whenever is needed. Two reasons: one is that there is a remote possibility that you will screw up your machines using commands not intended for everyday work; two, because it is useless, as having access to that or other system commands directories does not mean that you have the privileges to run them. In fact, when invoked as a "normal" user, the majority of those commands will fail or refuse to run.
Stick to the Unix way of doing things: The system architecture and the philosophy behind it have proven to be extremely successful over the years
RichGags, .cshrc is the initialization file for the C shell: If you use bash, you won't have it. Also if you need to add this or some other paths to your .bashrc, do it so that any reference appears after the definition. Other than that, any place will do.

RichGags
2006-01-25, 06:45 AM CST
The system architecture and the philosophy behind it have proven to be extremely successful over the years.

Nicely put. I will take your advice. You have to understand, Ive been a Windows guy for 20 years...In other words, Ive been like a mushroom (kept in the dark and fed sh*t) :)

Anyway, I like explainations like you gave. Most people just say do this, do that, ... but dont say why. Thanks for your help.

Rich

stevew158
2006-02-17, 12:38 PM CST
Hello Im new to the this site and found it looking for the answer to the ifconfig problem. I have checked the path as mentioned above and /sbin is in roots PATH, when i run the command ifconfig i still get command not found, also if i run shutdown -r now i get commnad not found. I went to /usr/sbin and there ifconfig is not there. I have been using either redhat or fedora core since redhat 7.2 and have run all the fedora core versions. IM currently running FC4 and this is the only version that ifconfig hasnt worked in. I hope someone here can help me figure out whats wrong thanks in advance. Steve

jcliburn
2006-02-17, 04:47 PM CST
Make sure you have net-tools installed. Run

yum list net-tools

If it isn't installed, install it with

yum install net-tools

stevew158
2006-02-17, 06:27 PM CST
Ok i checked net-tools is already installed
net-tools.i386 1.60-52.fc4.1 installed
But i still get : -bash: ipconfig: command not found
when i run ipconfig

Thanks for the response tho, this has me puzzled on whats wrong

stevew158
2006-02-17, 06:28 PM CST
opsss ment ifconfig not ipconfig

w5set
2006-02-17, 06:35 PM CST
type in
which ifconfig
/sbin/ifconfig (my return from that command)