Running Firefox as root in a regular user's session is not supported. ($XAUTHORITY is /run/user/1000/gdm/Xauthority which is owned by radix.)

79,747

earthmeLon's warning is very important, and you should try to solve your problem without having to run Firefox as root.

However, if for some reason you really need to do that (I won't judge you), you can do this:

sudo -i

To start a root shell, then make a backup of root's .Xauthority if needed

test -f .Xauthority && mv .Xauthority .Xauthority.bak

Copy the file from your home to root's

cp -a /home/youruser/.Xauthority .Xauthority
chown root: .Xauthority

Then you can start Firefox with:

XAUTHORITY=/root/.Xauthority sudo firefox

Remember to exit the root shell when you've finished with it.

Also remember to unroll your .Xauthority backup when done:

sudo -i
test -f .Xauthority.bak && mv .Xauthority.bak .Xauthority
exit
Share:
79,747

Related videos on Youtube

Harrish Kumar
Author by

Harrish Kumar

Updated on September 18, 2022

Comments

  • Harrish Kumar
    Harrish Kumar almost 2 years

    How can I resolve this error?

    When I change owner and group of Xauthority file to root, Firefox runs, but it does not work. When I reboot the system, Xauthority automatically changes to its original owner and group name.

    P.S.: I'm using Ubuntu 18.04.

    • kukulo
      kukulo about 6 years
      Try to copy the xauthority file to /home/root directory.
    • Harrish Kumar
      Harrish Kumar about 6 years
      @kukulo its not working.
    • earthmeLon
      earthmeLon about 6 years
      You shouldn't be running things as root. You've probably heard that before, but you really shouldn't be running a browser as root. Have you tried with any other users? What problem are you trying to solve by running as root to begin with?
    • Pablo
      Pablo about 6 years
      @earthmeLon I know I know, but sometimes there are legit resons for that, in my case because I run debian 8 at my workplace and I want to have the latest firefox version, I downloaded firefox from the website and installed in /opt/firefox. As a user I am not able to do updated (because users are not allowed to write on /opt) and the only option to do an update for me is sudo /opt/firefox/firefox -> Help -> About Firefox and wait for the update to be downloaded and applied, then I close firefox. With this new feature has made my updates more difficult.
    • Pablo
      Pablo about 6 years
      @earthmeLon In my case I could/should have installed firefox on my $HOME and I wouldn't need to run firefox as root for the updates. I only run FF as root like I said not for browsing but for letting FF do an auto-update.
    • shevy
      shevy over 3 years
      People should not upvote earthmeLon's comment. Why? Simple: it does not solve the original issue. I came to the same problem here. Based on earthmeLon's comment I can not solve the issue. Pablo's answer below is much better, but also very cumbersome. I'd wish upstream developers would not make things impossible or so hard when it really is just based on weak assumptions (aka "the superuser is not allowed to do anything"; I even get that warning message when I am the superuser, on my own computer system. Why is software working against me here? I did not give permission to it to do so.).
  • rwitzel
    rwitzel over 5 years
    There is no .Xauthority file in the user's home folder. I got the location of the file from the error message (see original question), like Running Firefox as root in a regular user's session is not supported. ($XAUTHORITY is /run/user/1000/gdm/Xauthority which is owned by <MY_USER>.)
  • FelixJN
    FelixJN about 3 years
    I strongly suggest using firefox --safe-mode when starting as root. This way, security risks coming from extensions are reduced. OP's main concern is upgrading firefox using the internal upgrading tool, so extensions are not necessary.