LinuxQuestions.org
Visit the LQ Articles and Editorials section
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-28-2006, 10:40 AM   #1
yogaboy
Member
 
Registered: Oct 2004
Location: Londinium
Distribution: CentOs 4, OSX Tiger
Posts: 93

Rep: Reputation: 15
sudo - permission denied!


Hi,

I have an admin account and I use sudo within that to run anything as root, but sometimes I get permission denied. If I log in as root and perform the same action then it works.

It just happened again with this command

$ sudo cat id_rsa_newkey.pub >> authorized_keys
-bash: authorized_keys: Permission denied


root is the owner and group on the file permissions. I thought sudo made me root for the current command? Am I missing something?


Any input is much appreciated.
 
Old 12-28-2006, 10:44 AM   #2
yogaboy
Member
 
Registered: Oct 2004
Location: Londinium
Distribution: CentOs 4, OSX Tiger
Posts: 93

Original Poster
Rep: Reputation: 15
just to add to this, if I run

sudo vi authorized_keys

I can open and alter the file.
 
Old 12-28-2006, 10:58 AM   #3
jstephens84
Senior Member
 
Registered: Sep 2004
Distribution: (Home)Opensolaris, Ubuntu, CentOS, (Work - AIX, HP-UX, Red Hat)
Posts: 2,056

Rep: Reputation: 94
sudo gives you root permissions. It does not change your user to root. for that you must do
Code:
su - root
At least that's how I have always understood it.
 
Old 12-28-2006, 11:08 AM   #4
yogaboy
Member
 
Registered: Oct 2004
Location: Londinium
Distribution: CentOs 4, OSX Tiger
Posts: 93

Original Poster
Rep: Reputation: 15
Quote:
sudo gives you root permissions. It does not change your user to root.
ok, I ran
ls -al

-rw-r--r-- 1 root root 785 Dec 28 15:44 authorized_keys

so it would seem that su makes you root and sudo adds you to the root group (for the duration of the command), which confirms what you are saying.

Thanks for the help, I've seen quite a few discussions/articles on su vs sudo but I've never seen anyone mention this difference. I will watch out for that in future.
 
Old 12-28-2006, 12:18 PM   #5
jstephens84
Senior Member
 
Registered: Sep 2004
Distribution: (Home)Opensolaris, Ubuntu, CentOS, (Work - AIX, HP-UX, Red Hat)
Posts: 2,056

Rep: Reputation: 94
A good way to look at it from a windows prospective is that sudo is like adding a user to the administrators group. They have admin rights but they still are not the administrator. su - root is basically saying I want to become root user.
 
Old 12-29-2006, 12:58 AM   #6
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
I think the problem is that a command of the form
Code:
command >>output_file
opens output_file before running command. So, you're attempting to open output_file before your uid has changed.
 
  


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
can't execute c++ binaries, "permission denied"... even though permission is 777 SerfurJ Programming 14 02-20-2009 05:50 AM
"sudo mount -a" works perfect but permission denied when mounting on startup, why? aaron4katie Linux - Software 10 01-11-2007 11:16 AM
sudo permission denied Swift&Smart Slackware 5 07-13-2006 02:05 AM
sudo and smartctl /dev/hda permission problem on Slackware 10.2 emphaze Linux - General 2 06-21-2006 08:47 AM
permission denied Ryan450 Linux - Software 2 01-19-2005 06:25 PM


All times are GMT -5. The time now is 11:41 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration