Just created a user from the Ubuntu user management window on my laptop. Confirmed the /home/newuser directory was created.

So I open a terminal window, su into the new user account and that works OK. When I try opening pluma, gedit, firefox or any X application, I get:

Error: cannot open display: :0.0

Other user accounts on the same laptop are able to open these same applications via command line. Just not this newly created account (from the User Management gui using defaults).

What gives?

  • 1
    @Zanna perhaps you are thinking of xhost? Commented Dec 2, 2016 at 13:34
  • It does not work because that other user is not allowed to write (open windows) in your desktop environment. It works if you log out and log in as that user, or if you use some special tool, like @steeldriver suggests. (If there is an ssh server, you can also use 'ssh -X`into the same computer, but it is 'overkill' and adds unnecessary overhead).
    – sudodus
    Commented Feb 25, 2017 at 19:42
  • @Zanna, I can answer using ssh -X, but I have not used xhost so that would be for you or @steeldriver to elaborate :-)
    – sudodus
    Commented Feb 25, 2017 at 19:49
  • @Zanna, It works for me with xhost and gksu. I added a paragraph about it in my answer.
    – sudodus
    Commented Feb 26, 2017 at 8:40
  • Awesome, thanks very much for answering @sudodus
    – Zanna
    Commented Feb 26, 2017 at 8:45

1 Answer 1



Graphics from an "su'd user" does not work because that other user is not allowed to write (open windows) in your desktop environment. It works if you log out and log in as that user, or if you use some special tool, like steeldriver suggests.

The light-weight solution is using xhost and gksu, but there might still be some problems because you [try to] write, where you are not 'supposed to' write.

Using an ssh server and ssh -X into the same computer is 'overkill' and adds unnecessary overhead, but can be used if you want to run like that once in a while (particularly if you have the ssh server installed already for other purposes). ssh -X works in a very reliable way with most GUI programs.

xhost and gksu

It is possible to run graphical programs as another user with xhost and gksu. It is important to use gksu to avoid overwriting your configuration files with those of the other user. This can create problems for you to run the same GUI program as your own user, the same problem as if you run GUI programs with sudo. In other words, use gksu or gksudo with GUI programs.

Text after the character # is a comment and not used.

In newer versions of standard Ubuntu you must install gksu

sudo add-apt repository universe  # at least in live and persistent live systems
sudo apt-get update
sudo apt-get install gksu

Prepare with xhost

xhost local:other-user           # general
xhost local:sudodus              # example, use the actual user ID

Now it should work to use gksu to run a program as the other user

gksu -w -u other-user gedit file-to-edit   # general
pwd > i-am-here                            # only to show 'where you are'
gksu -w -u sudodus gedit i-am-here         # example

I noticed that the current directory of gedit will be the original user's directory. And the other user should not write there. In other words, it is a good idea to use the full path to the file to edit, or use for example

gksu -w -u sudodus gedit /home/sudodus/file-to-edit  # example

When you do a simple text mode su

su - other-user                  # general
su - sudodus                     # example

the current directory will be the home directory of the other user.

See Eliah Kagan's answer at this link for more details

askubuntu.com/questions/168815/how-to-get-graphical-display-when-executing-commands-as-another-user ...

Look for Running Graphical Commands Directly as Another User

ssh -X

ssh (text only) and ssh -X (also graphics) are intended for log in to another computer, but it can be used locally too, if you have installed an ssh server, for example

sudo apt-get install openssh-server

I can log in like this

$ ssh -X [email protected]
The authenticity of host ' (' can't be established.
ECDSA key fingerprint is SHA256:XZBdC58tpt8ud63Z7DfZRX9DYp4xPq6uh0aI07fLlqg.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (ECDSA) to the list of known hosts.
[email protected]'s password: 
Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-64-generic i686)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

9 paket kan uppdateras.
0 uppdateringar är säkerhetsuppdateringar.

Last login: Tue Feb 14 13:51:52 2017 from
sudodus@xenial32 ~ $ 

Now, if I start for example firefox, it will work. Some graphical programs might not work, but most programs work this way. See the following links


askubuntu.com/questions/886313/what-is-the-simplest-way-to-have-remote-gui-access ...

You must log in to answer this question.

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