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.

  • Try to copy the xauthority file to /home/root directory.
    – kukulo
    May 16, 2018 at 16:47
  • @kukulo its not working. May 16, 2018 at 17:03
  • 4
    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?
    – earthmeLon
    May 16, 2018 at 18:50
  • 2
    @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
    May 23, 2018 at 16:51
  • @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.
    – Pablo
    May 23, 2018 at 16:52

1 Answer 1


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
  • 4
    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>.)
    – rwitzel
    Nov 23, 2018 at 14:38
  • 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.
    – FelixJN
    Apr 25, 2021 at 17:24

You must log in to answer this question.

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