LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problem running ifconfig as non root (https://www.linuxquestions.org/questions/linux-newbie-8/problem-running-ifconfig-as-non-root-389469/)

wrybread 12-05-2005 10:45 AM

Problem running ifconfig as non root
 
I'm trying to run ifconfig as a non root user, with the following command:

su - root ifconfig

It prompts me for root password, I enter it correctly, then get the following error:

"/sbin/ifconfig: /sbin/ifconfig: cannot execute binary file"

Anyone have a clue?

I know I can just login as root, but I'd really like to be able to execute root commands as non root every now and again.

reddazz 12-05-2005 11:10 AM

Code:

su -c "ifconfig"

wrybread 12-05-2005 11:16 PM

Nope, that produces same problem.

[wrybread@localhost ~]$ su -c "ifconfig"
Password:
bash: ifconfig: command not found

reddazz 12-05-2005 11:45 PM

My bad,
Code:

su -c "/sbin/ifconfig"

jrdioko 12-06-2005 12:12 AM

Quote:

Originally Posted by wrybread
I'm trying to run ifconfig as a non root user, with the following command:

su - root ifconfig

You have the right idea, but you shouldn't be putting it all on one line:

Code:

su -
<your password when prompted>
ifconfig

Quote:

Originally Posted by wrybread
I know I can just login as root, but I'd really like to be able to execute root commands as non root every now and again.

And that's exactly how you should be doing it. It's a very bad idea to login as root, as you can easily mess up your system if you mistype something, and it can become a security issue as well.

chrism01 12-06-2005 12:27 AM

If you are going to be using this cmd a lot, look into using the sudo facility.

Ynot Irucrem 12-06-2005 01:10 AM

Quote:

Originally Posted by reddazz
Code:

su -c "ifconfig"

this doesn't work because ifconfig isn't in the user's $PATH. You need to either specify the complete path to the binary with
Code:

su -c "/sbin/ifconfig"
or get the root's environment, with
Code:

su -c "ifconfig" -
EDIT: or add /sbin to your path, but you wouldn't want to do that.

reddazz 12-06-2005 07:01 AM

Quote:

Originally Posted by Ynot Irucrem
this doesn't work because ifconfig isn't in the user's $PATH. You need to either specify the complete path to the binary with
Code:

su -c "/sbin/ifconfig"
or get the root's environment, with
Code:

su -c "ifconfig" -
EDIT: or add /sbin to your path, but you wouldn't want to do that.

Err, did you not see the correction I made above. Cheers.

Ynot Irucrem 12-06-2005 07:12 AM

Sorry, I guess since your posts were close together, and almost identical, I must have glazed over the second one.

reddazz 12-06-2005 07:30 AM

Quote:

Originally Posted by Ynot Irucrem
Sorry, I guess since your posts were close together, and almost identical, I must have glazed over the second one.

Its alright. I was just messing around. I am guilty of doing the same thing on other peoples threads. :)


All times are GMT -5. The time now is 02:08 PM.