LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Starting firefox under a different user (https://www.linuxquestions.org/questions/linux-software-2/starting-firefox-under-a-different-user-867700/)

bartonski 03-10-2011 08:11 AM

Starting firefox under a different user
 
I've set up a second user for myself on my laptop.

My user on the laptop is 'tiger'

Let's call the second user 'jrdobbs'

I would like to log on to gmail/facebook/etc using the jrdobbs, but I don't want to switch users via X... I just want a second instance of firefox open, which stores all of its login information under /home/jrdobbs.

My naive attempt looked like this:

Code:

su -l -c "firefox" jrdobbs
Here was my thinking:

  • start firefox under 'su jrdobbs' ... firefox should store its files under the current user's $HOME/.mozilla
  • use the -l (login) flag for 'su', so that I know that I'm using jrdobbs' $HOME, rather than inheriting mine.
This gives the following:

Code:

$ su -l -c firefox jrdobbs
Password:
Error: no display specified

So I changed firefox to "firefox --display $DISPLAY"

This gives the following:

Code:

$ su -l -c "firefox --display $DISPLAY" jrdobbs
Password:
No protocol specified
No protocol specified
Error: cannot open display: :0.0

Because I double-quoted "firefox --display ... ", $DISPLAY is expanded to :0.0 before the su command is executed... I thought that this was what I wanted, because I want firefox to show up on tiger's display... however :0.0 is interpreted relative to the current user, and jrdobbs doesn't have a display named :0.0.

I also tried the following:

Code:

$ ssh -X jrdobbs@localhost firefox
This works, but I worry about overhead... my laptop gets plenty hot when I start running flash intensive apps, and that's even before I start encrypting packets...

repo 03-10-2011 10:04 AM

As tiger in a terminal type:
Code:

xhost 127.0.0.1
sudo -u jrdobbs -H firefox

Kind regards

bartonski 03-10-2011 07:49 PM

repo, thanks, I forgot about xhost.

Still no dice:

Code:

$ xhost 127.0.0.1
127.0.0.1 being added to access control list
$ sudo -u jrdobbs -H firefox
[sudo] password for tiger:
No protocol specified
No protocol specified
Error: cannot open display: :0.0


bartonski 03-11-2011 12:41 PM

Just found this: http://pr0gr4mm3r.com/linux/how-to-s...ser-in-ubuntu/

according to the article, the magic seems to look like this:

Code:

xhost +local:jrdobbs
I'll give it a try when I get home...

bartonski 03-12-2011 02:27 PM

That worked like a champ.

thebunnyrules 12-15-2016 11:48 PM

THANKS!!!!!! YOU GUYS ARE LIFESAVERS!

Just to sum it up for anyone else that's looking for this answer (it wasn't super clear for me when I was reading the thread):

To launch GUI apps as another user, you input the following command only once:

xhost +local:usersname

and then you only need to use use this command:

sudo -u usersname -H APPSname

Dominic108 10-09-2019 12:59 AM

For the benefits of people relying on this old post, note that this solution is incorrect.
 
I know it's an old post, but it is still relevant today. At the least on Ubuntu, the command
Code:

xhost +local:jrdobbs
gives access to every local user to the running X server. The part "jrdobbs" after "local:" is simply ignored. To check this fact, simply execute the command xhost by itself to get the current status. You will see that the local user "jrdobbs" was not added. Instead, "LOCAL:" was added. If one wants to give access to the specific local user jrdobbs, the command is
Code:

xhost +SI:localuser:jrdobbs
To have it at every reboot, one must put this command in ~/.profile. See askubuntu.com/questions/877820/what-are-xhost-and-xhost-si for more details.


All times are GMT -5. The time now is 01:00 PM.