Is there a way to start an application as another user so that the started application would use the other user's preferences/history/resources et al?

For example: I've logged in as Alice and I'd like to start Firefox as Bob, so therefore Firefox would show Bob's browsing history instead of Alice's.

I tried

$ su Bob
$ open -a Firefox

But with no apparent effect; as a matter of a fact Activity monitor shows the Firefox process is being run by Alice—not Bob.

I understand I will need Bob's login credentials, but that's not a problem.


From the command line you have to find the Unix executable and run it using sudo like so:

$ sudo -u Bob /Applications/Firefox.app/Contents/MacOS/Firefox 

… or the same with su: (however this also needs you to set up a password for root - which I do not recommend)

$ su Bob
$ /Applications/Firefox.app/Contents/MacOS/Firefox

(…or the above in one line:)

$ su Bob -c /Applications/Firefox.app/Contents/MacOS/Firefox

In the past, the easiest way for PPC Macs was to use Pseudo, but it has been long discontinued. This is to drop the application icon on Pseudo's icon or window.

  • Ah, the key was to find the Unix executable. It works also with su if one wishes not to sudo. Thanks! Sep 24 '11 at 20:33
  • Hmm, when trying to run Google Chrome I get this: Trace/BPT trap: 5 Dec 20 '12 at 5:32
  • When using the sudo approach I get login failures even though I use the correct password for the other user. su works on the other hand (no password for root set) Jul 31 '16 at 20:34
  • @lapplandscohan sudo takes the password of the current user
    – mmmmmm
    Aug 2 '16 at 19:46
  • 1
    @evan.bovie YTes shows they have thought of security
    – mmmmmm
    Dec 8 '17 at 9:41

See https://apple.stackexchange.com/a/102105/1860 for why su does not work for all applications.

launchd's bsexec

Recent versions of launchd have the ability the launch applications within another user's session; although Apple engineers have not recommended its general use.

Use the bsexec option in launchctl to target the appropriate user session:

 bslist [PID | ..] [-j]
          This prints out Mach bootstrap services and their respective states. While the namespace
          appears flat, it is in fact hierarchical, thus allowing for certain services to be only avail-
          able to a subset of processes. The three states a service can be in are active ("A"), inactive
          ("I") and on-demand ("D").

          If [PID] is specified, print the Mach bootstrap services available to that PID. If [..] is
          specified, print the Mach bootstrap services available in the parent of the current bootstrap.
          Note that in Mac OS X v10.6, the per-user Mach bootstrap namespace is flat, so you will only
          see a different set of services in a per-user bootstrap if you are in an explicitly-created
          bootstrap subset.

          If [-j] is specified, each service name will be followed by the name of the job which regis-
          tered it.

 bsexec PID command [args]
          This executes the given command in the same Mach bootstrap namespace hierachy as the given

 bstree [-j]
          This prints a hierarchical view of the entire Mach bootstrap tree. If [-j] is specified, each
          service name will be followed by the name of the job which registered it.  Requires root priv-

The recommended approach is to write a launchd job ticket and restart the Mac - or ask the user to log-out and back in again.


One more method:

# chown someuser command
# chmod u+s command
$ ./command

Thanks to wysota at : http://www.qtcentre.org/threads/4730-Linux-Bash-Run-a-command-as-another-user

(Spent a lot of time hunting for something that works in my particular situation, figured I'd spread the wealth)


You need to ssh. I.e. ssh username@123.456.00. As you said, you'll need the password for the user. Then you can do what you're asking. You'll need to enable remote login under System Prefs>Sharing:
Remote Login Preference
Then, you can just do open -a Firefox and Firefox will open as the other user, not yours.

  • Unfortunately I get: LSOpenURLsWithRole() failed for the application /Applications/Firefox.app with error -10810. when trying open -a Firefox :-| Sep 24 '11 at 20:28
  • @koiyu Try sudo open -na Firefox
    – daviesgeek
    Sep 24 '11 at 20:35
  • it fails as above :-/ (also using the path to the unix executable fails, albeit differently.) Sep 24 '11 at 20:43
  • 1
    Processes started from an SSH session do not have access to the GUI. If this works on your system I suspect you changed some low-level configuration at some point.
    – Tobias
    Sep 25 '11 at 8:30
  • 1
    @daviesgeek but did you SSH into a user other than the one who currently has the GUI, as the OP wanted.
    – Tobias
    Sep 25 '11 at 22:26

You must log in to answer this question.

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