Execute GUI programs as root under Linux (Fedora 26)

If you ever needed to run programs with a GUI, like nautilus/gedit/etc., as an administrator under Linux it was fairly easy, but now things slightly changed and you are not able to run them as it used to be…

Some time ago you had some options to run GUI apps as root:

  1. You could run them as root; would require root password

    su -c gedit
    
  2. Run them as yourself, with root privileges; would require your user password

    sudo gedit
    

When running those command on my Fedora 26 machine, I encountered an error.
It seems like newer systems prevent the superuser from running GUI applications on the X11-Server/ Wayland, so you might get the following error messages:

No protocol specified
Unable to init server: Could not connect: Connection refused

and/ or

Gtk-WARNING **: cannot open display: :0

Here the fix o run GUI apps as root again:
Type in terminal, while you are still the active user:

xhost +local:

Press enter, and taddaaa, now you are able to run your programs as root again.
So now you can run e.g. gedit with the command

sudo gedit

again.