I've been trying to run apps as a different user.

Attempt 1
sudo -u otheruser open /Applications/TextEdit.app launches the app but it uses the current user, not otheruser.

Attempt 2
login username and su - otheruser successfully login as otheruser, the different user pops up in Activity Monitor, but something like open /Applications/TextEdit.app returns the error LSOpenURLsWithRole() failed with error -10810 for the file /Applications/TextEdit.app.

Attempt 3
sudo su - otheruser -c /Applications/TextEdit.app/Contents/MacOS/TextEdit seems to launch the app (it appears under Activity Monitor as launched by otheruser) but this error appears while the dock icon bounces indefinitely: _RegisterApplication(), FAILED TO establish the default connection to the WindowServer, _CGSDefaultConnection() is NULL.

So… how do I run an app as a different user?


The answers to this question don't seem to be completely correct for me on 10.8 Mountain Lion. I think demure has a typing error at point 2, there must be something else than the "-". What works for me: Your attempt 3, without su and -c.

sudo -u testuser /Applications/TextEdit.app/Contents/MacOS/TextEdit

This opens TextEdit as testuser, and i could save a file to /. Saving to the user folder of testuser did not work, but that could be due to me giving this account very little rights at all since i use it for other test purposes. Interestingly, i could log-in as root as well even though i have the root user deactivated in KeyChain.app. This seems to only affect the Desktop log-in from root, not the Terminal log-in. The file i saved as testuser had the correct owning privilges etc. set.

$ cd /
$ ls -la | grep testuser
-rw-r--r--    1 testuser  staff      330 18 Okt 20:07 Untitled.rtf
  • Awesome, this works! A bit harder to use it, considering that I need to go and find the executable file, but this way I can actually use this to launch and use Photoshop — which for some reason doesn't work in my account, even after full reinstall and preferences cleanup. – fregante Jan 29 '14 at 1:15

Normally running a GUI app as a different user (except a few cases of gui software designed for root) doesn't really work.

This used to work, I am unsure if it still does on current macs. Verbatim:

This is regurgitating a hint I got from the comments section of another hint about Apache (I think). What this does is allow you to keep a program within the constraints of another user, without having that user logged in via the GUI. Run a suspect program within a bubble! I'd advise setting up a dummy account with very limited access if you wanted to make a "bubble." Note: I'm going to refer to the subsequent account as the "bubble account" and that account's session as the "bubble" from now on to give you the right idea about this.

  1. Open a new terminal window
  2. Type the following where short_name is the short name of the "bubble" account: sudo short_name -
  3. Type the password to the "bubble" account.
  4. Type the following where app_name is the name of the app you wish to open: /Applications/app_name.app/Contents/MacOS/app_name
    For instance, this would launch Safari:

A couple of things to remember (very important!):

  • Copying and pasting between this app and others will not work unless the others are also in the bubble.
  • Apps running from within the bubble will still be able to launch subsequent applications under the original account (from what I can tell). For instance, going to an ftp:// URL in Safari while it's in the bubble will use the Finder running in the non-bubble account, with all available privileges.
  • Closing the terminal (or hitting Ctrl+C while in the window) will close the app running within the bubble. Many programs will show exceptions and weird messages in the Terminal at various times while the program is running, if you've programmed before you'll know this is totally normal and expected.
  • The programs running in the bubble may have different appearance settings than those you would otherwise run. To change this, login under the bubble account and go to System Preferences
  • Running two copies of a program (one inside and one outside the bubble) works absolutely perfectly, in fact I'm writing this on my "bubbled" Safari app right now!
  • Some problems may occur, like not being able to drag and drop using Safari. Work around them *This does not seem to save preferences with the bubble account as file vault if the user is not logged in in the background.

And another hack-ish method. But both the following examples are for X11 apps

sudo -i -u other_user \`  


xauth extract -f - "$DISPLAY" |`  
sudo -u other_user xauth -f ~other_user/.Xauthority merge -`
  • Please include the basic steps of your suggestions in your answer, links die. – terdon May 16 '13 at 9:28
  • @terdon would you advise putting the serverfault.com info in verbatim, as well? – demure May 16 '13 at 12:32
  • Not necessarily verbatim, it is just the policy on the SE network to provide at least the basic steps rather than an external link. See here for a discussion. Basically, we expect answers to be answers not links to where an answer might be found. – terdon May 16 '13 at 12:35
  • sudo short_name - says short_name: command not found (short_name was replaced with the username). I don't know about X11 apps, I don't use any. – fregante May 25 '13 at 12:39

Just in case someone is still looking for a way to do this, I found this app:

RUN AS http://josephbeeson.com/index.php?page=proj_en

That's working for me. (testing it with box.com sync app at the moment)

  • Sweet! That actually works (in OS X 10.8)! I tried with TextEdit and it even shows the other user's Home in the open/save dialog. Thanks, and welcome to StackExchange :) – fregante Jan 29 '14 at 1:05
  • 1
    Link is dead. Does this still work? – Jason Nov 27 '17 at 23:18

Use open to launch an application.


-a option - open filename using application TextWrangler-:

 sudo su - david  -c "open -a TextWrangler filename"

-e option - open myfilename using application TextEdit-:

sudo su - user  -c "open -e myfilename"
  • 1
    This is not different from my third attempt, I still get the error LSOpenURLsWithRole() failed for the application /Applications/TextEdit.app with error -10810. – fregante May 25 '13 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.