LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-01-2015, 02:52 PM   #1
hnasr2001
Member
 
Registered: Nov 2012
Posts: 98

Rep: Reputation: Disabled
run a script in boot as user using /etc/rc.local


I am trying to run a script at boot using /etc/rc.local.
it works fine but runs as root and I want to run it as user.
I tried sudo -u user /path-to-file and it didn't work (the script didn't run).
Any solution will be appreciated.
 
Old 12-01-2015, 02:58 PM   #2
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
See man setuid and man setuidgid.
 
Old 12-01-2015, 03:42 PM   #3
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
How about "su - user -c command"?
 
1 members found this post helpful.
Old 12-01-2015, 04:02 PM   #4
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
su will work, too.

Below is a live example with setuidgid.
Code:
#!/bin/sh
exec setuidgid sarah /usr/local/bin/mplayer -quiet http://...
 
1 members found this post helpful.
Old 12-05-2015, 08:32 PM   #5
hnasr2001
Member
 
Registered: Nov 2012
Posts: 98

Original Poster
Rep: Reputation: Disabled
Thanks everyone - su worked.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Add user on raspbian + run a script on logon + logoff when user exits script EdgarE Linux - Newbie 7 09-07-2015 10:03 AM
[SOLVED] run a boot-up script as user hnasr2001 Linux - General 3 02-03-2015 10:22 AM
[SOLVED] run a script during boot up as a user hnasr2001 Linux - General 2 12-30-2014 05:35 PM
Execute script on local server as normal user to run commands on remote server ALInux Linux - Software 1 01-01-2010 06:30 AM
How to run a script with a boot/reboot with the ownership of a user avijitp Linux - Server 2 11-03-2006 09:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:13 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
Open Source Consulting | Domain Registration