# Sudo: Cannot open display

## kimczuba

Problem:

Executing X-apps via sudo generates the error 

```
some program... Cannot open display
```

To avoid this, do as follows:

Add the line:

```
Defaults:czuba env_keep=DISPLAY
```

and the line:

```
USER HOST=PATH TO PROGRAM
```

to the file /etc/sudoers.

The first line says that when user czuba uses sudo, then he shall keep his DISPLAY variable (and only the user czuba).

The second line says that the user USER on host HOST can execute the program pointed to by PATH TO PROGRAM.

An example:

I would  like to run the program ethereal. Then the last line would be:

```
kimczuba mithrandir=/usr/bin/ethereal
```

Now you can run ethereal via the command:

```
sudo ethereal
```

Hope this helps some of these posts:

 :Arrow:  https://forums.gentoo.org/viewtopic-t-288668-highlight-sudo+display.html

 :Arrow:  https://forums.gentoo.org/viewtopic-t-252412-highlight-sudo+display.html

 :Arrow:  https://forums.gentoo.org/viewtopic-t-272318-highlight-ethereal.html

 :Idea:  The file /etc/sudoers actually contains much usefull information on how to set sudo up, so it is a good place to start. Happy sudoing.

----------

## adaptr

Excellent!

Next time put it in D, T & T so the mods don't have to move it there... :Wink: 

----------

