LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-17-2007, 12:58 PM   #1
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,752

Rep: Reputation: 463Reputation: 463Reputation: 463Reputation: 463Reputation: 463
Start a program for a user as root, with process belonging to user


I'm trying to to start a process while running as root. But I want the program to run on a users desktop and have the process belong to the user and not root.

I've been doing something like this:
sudo $USER
xauth merge /home/$USER/.Xauthority
export DISPLAY=:0.0
/usr/bin/myprogram &

this will start the program alright, but the process belongs to root and not to $USER. How do I get this process to be owned by the $USER?
 
Old 03-17-2007, 02:36 PM   #2
gamma9mu
LQ Newbie
 
Registered: Mar 2006
Location: LitH, IL
Distribution: Ubuntu Feisty
Posts: 6

Rep: Reputation: 0
try:

sudo -u $USER [command]
 
Old 03-17-2007, 03:29 PM   #3
Valkyrie_of_valhalla
Member
 
Registered: Jan 2006
Location: Romania
Distribution: Suse 12.0, Slackware 12.1, Debian, Ubuntu, Gentoo
Posts: 301

Rep: Reputation: 30
or maybe

su $USER

this should run all the commands that follow as the user stored in the variable
 
Old 03-19-2007, 05:09 AM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,752

Original Poster
Rep: Reputation: 463Reputation: 463Reputation: 463Reputation: 463Reputation: 463
Neither of those will work.
The user is logged in and running X. I am running a shell script as root which I want to start a GUI application on the users desktop, but the process should belong to the user.
 
Old 03-19-2007, 01:58 PM   #5
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,445

Rep: Reputation: 829Reputation: 829Reputation: 829Reputation: 829Reputation: 829Reputation: 829Reputation: 829
You have to put them inside the shell script:

Code:
xauth merge /home/$USER/.Xauthority
export DISPLAY=:0.0
su $USER -c '/usr/bin/myprogram' &
 
  


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
C program to see user log on in system and print user with real user name also naveen245 Programming 2 12-21-2005 12:53 AM
Boot process as non-root user fatman Debian 6 06-07-2005 04:08 PM
start a X program as different user, how? IamDaniel Linux - General 1 01-30-2005 11:46 PM
I can start X with root but not with another user pewillette Linux - Newbie 4 04-21-2004 06:58 PM
Getting a program to start with root privileges when a user logs in. joeking Linux - Security 4 10-24-2003 11:47 AM


All times are GMT -5. The time now is 01:22 PM.

Main Menu
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