Ubuntu – Firefox only runs with `sudo`

configurationfirefoxmozillapermissionssudo

I have to run sudo firefox to open my Firefox browser. If I try to open it normally it doesn't work.

When I do not use sudo, the error message is:

Your Firefox profile cannot be loaded, it may be missing or inaccessible.

The output of the command itself is Permission denied. This is with Firefox 50.1.0. How to fix it?

Best Answer

Although it's probably fine to (re)take ownership of everything in your home directory, the specific reason you were unable to start Firefox is that your Firefox profile was inaccessible when you didn't run firefox with sudo.Therefore, I recommend retaking ownership of just the folder that contains your Firefox profile and other user-specific Firefox data (like your Firefox extensions):

sudo chown -R $USER:$USER ~/.mozilla

That will work if you enter it exactly as written. Or, if you like, you can replace $USER with your username. If you do that, make sure you do not keep the $.

(You may also use $(whoami):$(whoami) instead of $USER:$USER, as in L.D. James's answer, if you want.)

Make sure Firefox is not running when you execute that command.

Then open Firefox. It should run, now.


Your problem was most likely caused by running Firefox with sudo in the first place. In the case of a program like Firefox, you should just not run it as root -- there is never really any situation where it would be useful to do so.

In general, however, if you find you must run a graphical application as root, you should almost never use plain sudo for that, since it causes any configuration files the application creates to be owned by the root user but still be created in your home directory rather than root's.

Instead, you can use gksu, gksudo, kdesudo (on Kubuntu), sudo -H, or sudo -i when you encounter a situation where you must run a graphical program as root. However, I emphasize that running programs as root is for system administration. You might decide to run a text editor as root to edit the system's configuration files, but you never need to, and never should, run a program like a web browser or word processor as root.