1

I am trying to start firefox from terminal using this command sudo /usr/bin/firefox. The problem is that it won't open firefox returning me this error:

mkdir: cannot create directory '/run/user/0': Permission denied
Authorization required, but no authorization protocol specified
Error: cannot open display: :0

Does anyone know how I can fix this? Thank you.

Harry
  • 21
  • 10
    Why are you trying to open Firefox as root? Not a good idea. All you have to do is run firefox. If you have been running graphical software as root you may have much deeper problems with permissions. – ChanganAuto Aug 15 '22 at 16:37
  • 2
    please [edit] your question with the version of ubuntu you are using and whether you are using server of gui versions of ubuntu? Why do you want to open it from the command line? – graham Aug 15 '22 at 16:42
  • I am with @ChanganAuto and that IS the problem, Run it without sudo please. and this only works when done on commandline using terminal in a desktop. – Rinzwind Aug 15 '22 at 16:46

1 Answers1

5

The "sudo" command is used to temporarily grant administrator (root) permission, but running a web browser with the root user is not recommended and generally not necessary, considering that you don't need to be an administrator to browse the internet.

You can start firefox via command line with command /usr/bin/firefox & or just firefox &

The character "&" after the name of the executable guarantees that it will not terminate when the terminal session is closed or if you press the key combination CTRL + C, because with the character & the application will remain running in the background.

Running programs in the background from terminal