Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-13-2011, 09:08 PM   #1
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, 09:31 PM   #2
Registered: Oct 2009
Location: Michigan
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, 10:00 PM   #3
LQ Guru
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mageia, and whatever VMs I happen to be playing with
Posts: 12,871
Blog Entries: 18

Rep: Reputation: 3340Reputation: 3340Reputation: 3340Reputation: 3340Reputation: 3340Reputation: 3340Reputation: 3340Reputation: 3340Reputation: 3340Reputation: 3340Reputation: 3340
You might want to look into setuid.
Old 10-13-2011, 10:13 PM   #4
Senior Member
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

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


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

All times are GMT -5. The time now is 01:42 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration