LinuxQuestions.org
Review your favorite Linux distribution.
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 05-15-2011, 11:01 AM   #1
vanish78
LQ Newbie
 
Registered: May 2011
Posts: 13

Rep: Reputation: 9
How to edit /etc/sudoers so that I can run another users script


Hi,

I'm a newbie so please help, and if this is the wrong forum guide me to the correct one thanks.

I want to run a script owned by another user. It should not be run by root.
I have edited the sudoers file but it runs the script as root, I want it to run it as user grid?

This is what I have so far :

udo -l
User oracle may run the following commands on this host:
(root) /home/grid/asm_test.sh


cat /etc/sudoers

# User_Alias ADMINS = jsmith, mikem
User_Alias MAINTAINERS = oracle

## Command Aliases
## These are groups of related commands...
Cmnd_Alias DEB = /home/grid/asm_test.sh



## Allow root to run any commands anywhere
root ALL=(ALL) ALL
MAINTAINERS ALL=DEB

Please help, I'm stuck
 
Old 05-15-2011, 11:03 AM   #2
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Rep: Reputation: 70
What about:
Code:
su - grid -c $command
 
Old 05-15-2011, 11:05 AM   #3
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
To run a script as another user with sudo you have to use the -u option, for example
Code:
sudo -u user2 myscript
To learn more about sudo's option try
Code:
man sudo
 
Old 05-15-2011, 11:10 AM   #4
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766
Blog Entries: 23

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
Hi,

Welcome to the forum...as far as I'm concerned, this is the right place, dont worry.

Okay, SUDO means that if you do this

Quote:
sudo somecommand
that you must have the rights to run somecommand as ... root. So far you're correct in editting the sudoers, but, as you become root (temp) you try to run the command as ... root.

Quote:
I want to run a script owned by another user. It should not be run by root.
As you say yourself, it should not be run as root.

What I can suggest is two things:

- place the script in a system-wide accessible spot (/opt/somefolder for example) and set the rights to the corect group, you and the "other user" belong to a group, well then. Make sure you're both in the same user group...
- copy the script to your own space, very quick, but very-very dirty...not the cleanest plan...

Good luck with this!

Thor
 
Old 05-15-2011, 01:37 PM   #5
vanish78
LQ Newbie
 
Registered: May 2011
Posts: 13

Original Poster
Rep: Reputation: 9
Thanks for the fast responses!

jamescondron : su - grid -c /home/grid/asm_test.sh , still asks for a password, I need to run it so it doesn't ask for a password

TobiSGD : I tried that but complains that the user is not in the sudoers file -

sudo -u grid /home/grid/asm_test.sh
Sorry, user oracle is not allowed to execute '/home/grid/asm_test.sh' as grid on avgo2db01.theavenggroup.com.

Thor_2.0 : I created a scripts directory /opt/scripts, moved the script but gives me the same permissions error:

/u01/app/grid/product/11.2.0/grid/bin/asmcmd: line 122: /u01/app/grid/product/11.2.0/grid/perl/bin/perl: Permission denied

Both users belong to the same group.

Last edited by vanish78; 05-15-2011 at 01:40 PM.
 
Old 05-15-2011, 01:46 PM   #6
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Deleted: Have read the previous post wrong. Sorry.

Last edited by TobiSGD; 05-15-2011 at 02:30 PM.
 
Old 05-15-2011, 02:28 PM   #7
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,766
Blog Entries: 23

Rep: Reputation: 411Reputation: 411Reputation: 411Reputation: 411Reputation: 411
Quote:
/u01/app/grid/product/11.2.0/grid/bin/asmcmd: line 122
Wow, wait a sec! You problem could well be in line 122, and not the script as a whole. Check what is being called there, and see if you're allowed to do that...

Thor
 
  


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
[SOLVED] After modifying /etc/sudoers file, new users can not run specified commands mansour Linux - Newbie 15 04-13-2011 11:04 AM
can I edit sudoers without vi? newbiesforever Linux - General 4 11-09-2009 11:13 PM
can I edit sudoers without vi? newbiesforever Linux - General 4 08-10-2009 01:35 PM
Edit sudoers by script snowman81 Programming 5 05-27-2008 06:52 PM
cannot edit /etc/sudoers unisol Ubuntu 13 06-18-2006 09:35 AM

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

All times are GMT -5. The time now is 05:21 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