Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 01-08-2010, 08:44 AM   #1
LQ Newbie
Registered: Jan 2010
Posts: 3

Rep: Reputation: 0
how to run a command under root as another user?

Hello all,

Nice to be here! Nice Forum!

So, i've a little question. I have a Linux Red Hat 5.1 System wich has a programm that needs to be started as a user -> usera .

When i reboot the server, how can i make it possible to run a command in the shell as usera user?

Someone told me, that this is not possible to make an autostart entry because this works only with the root account?!

What i want its simple.

- Command -> startprg need's to be started as user usera automatically after an automated reboot of the red hat linux.

What will you suggest me?

Thank's for your help!

Greetings Fab

PS: Linux Newbie....
Old 01-08-2010, 08:55 AM   #2
Senior Member
Registered: Jul 2008
Location: /dev/null
Posts: 1,173
Blog Entries: 12

Rep: Reputation: 129Reputation: 129
You can put in /etc/sudoers:

usera ALL=(ALL) NOPASSWD:/sbin/shutdown -r now
This will allow usera to reboot from cli without password. Is this what you are asking?
Old 01-08-2010, 10:55 AM   #3
LQ Newbie
Registered: Jan 2010
Posts: 3

Original Poster
Rep: Reputation: 0


But what i want is, after a reboot that i can start a command in the shell as usera. Because the problem is, that a tool was installed not as root but as usera. And this tool need's to run with usera credentials.

How and where can i add an etry that runs this command like starttool as user usera?

Greetings fab
Old 01-08-2010, 11:05 AM   #4
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Rep: Reputation: 62
You can add it to your rc.local script, and the command you are looking for is:

su - usera -c "<command>"
If that is run as root <command> will be execuated with the priveleges of usera.


Old 01-11-2010, 02:25 AM   #5
LQ Newbie
Registered: Jan 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Hi Alanduil,

Fine thanks. So i will do it like this.

Greetings fab


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run root privileged Linux command as normal user via shell shell tcegrid Linux - Newbie 1 06-23-2008 04:38 PM
why lftp command run failed when user isn't root, but ok when logining as root steven_yu Linux - Software 0 06-06-2007 09:36 PM
how to run root command having normal user permission ravi.patil Linux - Newbie 7 05-21-2006 03:21 PM
Hi, How to view user and root run command on linux? dEMax Linux - General 1 09-12-2003 05:22 AM
Is their a way to run a command as root..or another user.. in php BaerRS Programming 2 04-25-2002 03:38 PM > Forums > Linux Forums > Linux - General

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