LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 12-05-2005, 11:45 AM   #1
wrybread
LQ Newbie
 
Registered: Dec 2005
Posts: 9

Rep: Reputation: 0
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.
 
Old 12-05-2005, 12:10 PM   #2
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 74
Code:
su -c "ifconfig"
 
Old 12-06-2005, 12:16 AM   #3
wrybread
LQ Newbie
 
Registered: Dec 2005
Posts: 9

Original Poster
Rep: Reputation: 0
Nope, that produces same problem.

[wrybread@localhost ~]$ su -c "ifconfig"
Password:
bash: ifconfig: command not found
 
Old 12-06-2005, 12:45 AM   #4
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 74
My bad,
Code:
su -c "/sbin/ifconfig"
 
Old 12-06-2005, 01:12 AM   #5
jrdioko
Member
 
Registered: Oct 2002
Distribution: Debian 6.0.2 (squeeze)
Posts: 944

Rep: Reputation: 30
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.
 
Old 12-06-2005, 01:27 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
If you are going to be using this cmd a lot, look into using the sudo facility.
 
Old 12-06-2005, 02:10 AM   #7
Ynot Irucrem
Member
 
Registered: Apr 2005
Location: Perth, Western Australia
Distribution: Debian
Posts: 233

Rep: Reputation: 30
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.

Last edited by Ynot Irucrem; 12-06-2005 at 02:15 AM.
 
Old 12-06-2005, 08:01 AM   #8
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 74
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.
 
Old 12-06-2005, 08:12 AM   #9
Ynot Irucrem
Member
 
Registered: Apr 2005
Location: Perth, Western Australia
Distribution: Debian
Posts: 233

Rep: Reputation: 30
Sorry, I guess since your posts were close together, and almost identical, I must have glazed over the second one.
 
Old 12-06-2005, 08:30 AM   #10
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 74
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.
 
  


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
ifconfig RUNNING not there pyroman59 Linux - Networking 2 08-07-2005 02:17 PM
how to run ifconfig as root without super user terminal GUIPenguin Linux - General 1 01-15-2005 11:06 AM
eth0 not running ifconfig calderonr Linux - Networking 1 01-16-2004 02:14 AM
Problem with smbmount running as root linxtc Linux - Networking 2 10-18-2003 05:52 PM
ifconfig when non-root syl20 Linux - Networking 2 08-11-2003 11:25 AM


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

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