LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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, 10:45 AM   #1
wrybread
LQ Newbie
 
Registered: Dec 2005
Posts: 21

Rep: Reputation: 1
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, 11:10 AM   #2
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
Code:
su -c "ifconfig"
 
Old 12-05-2005, 11:16 PM   #3
wrybread
LQ Newbie
 
Registered: Dec 2005
Posts: 21

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

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

Rep: Reputation: 77
My bad,
Code:
su -c "/sbin/ifconfig"
 
Old 12-06-2005, 12: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, 12:27 AM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
If you are going to be using this cmd a lot, look into using the sudo facility.
 
Old 12-06-2005, 01: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 01:15 AM.
 
Old 12-06-2005, 07:01 AM   #8
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
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, 07: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, 07:30 AM   #10
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:53 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
Open Source Consulting | Domain Registration