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 10-13-2011, 08:08 PM   #1
veeruk101
Member
 
Registered: Mar 2005
Distribution: Ubuntu 12.04 LTS
Posts: 249

Rep: Reputation: 16
Can sudo be used to always run a specified program as a particular user?


I'd like to always run a particular program (e.g. Eclipse) as the apache user. I used to start this program by changing its launcher to call 'su apache -c "/path/to/eclipse"' rather than '/path/to/eclipse'. (This required me to change the login shell in /etc/passwd from nologin to something like bash.)

As I'm new to sudo, I'm wondering if sudo can be used to specify that anytime /path/to/eclipse is run, that it should automatically be run as the apache user (rather than as the currently logged in user)? I get the impression that sudo might allow for this, but I'm not sure. If it doesn't, what other options do I have for 'elegantly' always running this program when launched as a given user? I find that the launcher method I described above isn't the best, because if for whatever reason I launch it a different way, I have to remember to prefix it with 'su apache'.
 
Old 10-13-2011, 08:31 PM   #2
AuroraZero
Member
 
Registered: Oct 2009
Location: memphis, TN
Distribution: SlackWare 14.2, Android, Slax, Centos 5.9 Final, Centos 6
Posts: 188

Rep: Reputation: 32
As far as I know it can not be used to run a program. Only give users rights to run the program. I don't think it was intended to do anything but that.
 
Old 10-13-2011, 09:00 PM   #3
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,323
Blog Entries: 28

Rep: Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141Reputation: 6141
You might want to look into setuid.

http://www.cyberciti.biz/faq/unix-bs...x-setuid-file/
 
Old 10-13-2011, 09:13 PM   #4
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
No, but, if you log in as the user and do a chmod +s /path/to/eclipse, that should turn on the "set uid" for the executable to that specific user. Note that this will allow anyone with access to that executable to run it as that user. This is often considered a gross security risk, and a no-no on a system connected to the Internet.
 
  


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
run a user-defined command without sudo anurupr Programming 13 03-19-2013 11:28 AM
[SOLVED] "sudo: Can't mkdir /var/run/sudo/%user%: File exists" CNBarnes Linux - Server 7 01-10-2011 04:11 PM
Gconf-editor settings not sticking for root, sudo user, or user when run sandaili Fedora 1 07-19-2008 08:31 AM
sudo problem. Want permission to run a sbin program without a password inverted.gravity Linux - Software 11 03-21-2007 03:34 PM
allow sudo for www user to run root shell script cccc *BSD 12 07-23-2005 03:48 PM

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

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