sudo nautilus results in "cannot open display" error

10,820

From Arch Wiki:

By default, and for security reasons, root will be unable to connect to a non-root user's X server. There are multiple ways of allowing root to do so, if it is necessary.

Before running gksudo nautilus you should allow root access.
To do this run:

xhost +SI:localuser:root   

These also works: xhost local:root or just xhost +.

You can disallow with xhost -SI:localuser:root and xhost -.

See more here.

Share:
10,820

Related videos on Youtube

A T
Author by

A T

Updated on September 18, 2022

Comments

  • A T
    A T over 1 year
    $ gksudo nautilus
    Failed to connect to Mir: Failed to connect to server socket: No such file or directory
    Unable to init server: Could not connect: Connection refused
    
    (nautilus:6072): Gtk-WARNING **: cannot open display:
    

    Troubleshooting attempts:

    • Same error when using gksu and sudo.
    • Also tried export DISPLAY=:0.0.
    • Finally even tried installing lightdm-gtk-greeter and appending [SeatDefaults] in /etc/lightdm/lightdm.conf with greeter-session=lightdm-gtk-greeter

    BTW: I'm running Ubuntu 15.04 x64 on a System76 laptop.

  • A T
    A T over 8 years
    nautilus is just an example. Same error occurs when launching any GUI program from Terminal using sudo/su/gksudo/gksu.