LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 06-08-2004, 11:21 PM   #1
mpgram
Member
 
Registered: Sep 2003
Location: Dallas TX
Distribution: Red Hat
Posts: 59

Rep: Reputation: 15
Execute a command as another user


I am logged in as root. I want to execute a command as another user ($USER).

I am trying to do this from a command line with no scripting and all on one line.

This is for qmail for the ./Maildir/ functionality.

Does anyone have any ideas?

Thanks in advance
 
Old 06-08-2004, 11:30 PM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
I think you should be able to do something like "su -c MYCMD".

You can look up the details in "man su".
 
Old 06-08-2004, 11:33 PM   #3
mpgram
Member
 
Registered: Sep 2003
Location: Dallas TX
Distribution: Red Hat
Posts: 59

Original Poster
Rep: Reputation: 15
Yeah, thats what I have been trying, but either I am an idiot (very possible here) or what I am trying to do is not possible.

Here is what I am trying...

su - user -c /var/qmail/bin/maildirmake ~/Maildir

The problem is that the command is not accepting anything after the space.
 
Old 06-08-2004, 11:37 PM   #4
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Try putting the command in quotes:

su - MYUSER -c "/var/qmail/bin/maildirmake ~/Maildir"

PS:
Apologies in advance, but I'm booted to Micro$oft at the moment, so I can't test it out myself...
 
Old 06-08-2004, 11:38 PM   #5
mpgram
Member
 
Registered: Sep 2003
Location: Dallas TX
Distribution: Red Hat
Posts: 59

Original Poster
Rep: Reputation: 15
Tried that too...didn't work.
 
Old 06-08-2004, 11:43 PM   #6
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Sorry. Even though you said you didn't want to (or couldn't) go that route, it would be work it to wrap the "maildirmake" command and the "~/Maildir" argument together in a shell script to see if that solves the problem:

su - MYUSER -c MYSCRIPT_WITH_CMD_AND_ARGS
 
Old 06-08-2004, 11:45 PM   #7
mpgram
Member
 
Registered: Sep 2003
Location: Dallas TX
Distribution: Red Hat
Posts: 59

Original Poster
Rep: Reputation: 15
The reason I don't want to is becasue I do not know shell scripting yet.

Guess I have to learn that to progress.

Thanks for your help.
 
  


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
How to execute iptables command by the user apache ??? Bassam Linux - Security 2 10-28-2005 07:10 AM
remote command execute telnet with 1 command MPowers Linux - Networking 2 06-30-2005 06:31 AM
boot script execute command as non-root user wampfler Linux - Security 7 09-24-2004 04:56 AM
execute command as different user kilobravo Linux - General 2 06-02-2003 10:03 AM
Ordinary user can execute the "halt" command ederts Linux - Newbie 7 05-24-2001 11:18 AM


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