HOWTO: Gui Apps when you are root in Ubuntu

When you are the root user by typing

sudo -i

you can’t execute gtk apps, and you get the following message:

cannot open display: (null)

That’s made for security reasons. To enable executing GUI apps then follow the instructions:

When you are a normal user type:

xhost +

and you’ll get a message that says

access control disabled, clients can connect from any host

sudo -i

enter the password and type:

export DISPLAY=:0

and you are done!!


About jordilin

I'm a Senior Software Engineer with an MSc in Telecommunications Engineering. I've got a range of interests including Linux, a very powerful and limitless operating system, travelling, gastronomy and technology.
This entry was posted in HOWTOs, Ubuntu Linux. Bookmark the permalink.

2 Responses to HOWTO: Gui Apps when you are root in Ubuntu

  1. dappaman says:

    xhost + is not such a good idea it gives everybody access to you screen.
    How about giving only access to applications from your machine:
    xhost +localhost

  2. jordilin says:

    Yes, you are right, but I don’t know why it does not work. I have to disable the access control list. With xhost + localhost you are adding localhost to the access control list and that’s all. In any case, if that works for you, then that’s ok. In fact, it’s quite rare having to use a graphical tool being root in Ubuntu, and it’s more a curiosity than anything else, because with sudo you are done.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s