Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to create mozilla profile for another user from command line using su.

When I'm trying from X, this will work.

su myuser -c 'mozilla -CreateProfile newprofile'

But my goal is to embed this to a script and it will execute only in command line mode. If I try this, from a command line, It also works:

DISPLAY=1.0 mozilla -CreateProfile newprofile

The question is how to embed "DISPLAY" variable in "su" command, cause this fails:

su myuser -c 'DISPLAY=1.0 mozilla -CreateProfile newprofile'
share|improve this question

migrated from Sep 8 '10 at 12:43

This question came from our site for professional and enthusiast programmers.

Why is "linux" in the title if you say you are running SCO Unix? – grawity Sep 8 '10 at 21:09

Have you tried this:

su myuser -c 'export DISPLAY=\"1.0\"; mozilla -CreateProfile newprofile'

This should really be posted on

Try that variant by escaping the quotes in the variable DISPLAY...

share|improve this answer
Yes, I've tryed it. It fails too. – Anonymous Sep 8 '10 at 12:38

This works for me:

su sh -c 'DISPLAY=1.0  echo $DISPLAY'

what exactly is the error you are getting?

share|improve this answer
Unfortunately, this doesn't work for me. Maybe becouse of my OS - SCO Unix. Errors are only some perl warnings from 'locale', but I've got them also in X mode, so this is not the reason. Mozilla comand finishes, but without creating the profile. – user48777 Sep 8 '10 at 12:45
SCO Unix? Respect. – Janne Pikkarainen Sep 8 '10 at 12:49

What about this one:

su myuser -c "sh -c 'DISPLAY=1.0 mozilla -CreateProfile newprofile'"
share|improve this answer
No it fails too. – user48777 Sep 8 '10 at 14:15
And what does complain? – cYrus Sep 8 '10 at 14:17
It does not complain. it finishes cleanly, but profile directory is not created. Never mind, I solved the problem. Thanks for reply. – user48777 Sep 8 '10 at 14:45


su - -c 'DISPLAY=1.0 mozilla -CreateProfile newprofile' myuser
share|improve this answer
TEMPXAUTH=$(xauth nlist) su -c 'xauth nmerge <<< "$TEMPXAUTH" && mozilla -CreateProfile newprofile'

A temporary file would work too.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .