# SUDO SU - and $DISPLAY woes

## KhanReaper

Hello,

I have seen numerous posts on this topic, but none of them have been useful in solving my problems. Performing a ''sudo su -'' will not export the $DISPLAY variable to the new session. I am curious as to why this occurs, for my /etc/sudoers possesses the following characteristics that the community has suggested for a long while:

```
# sudoers file.

#

# This file MUST be edited with the 'visudo' command as root.

#

# See the sudoers man page for the details on how to write a sudoers file.

#

# Host alias specification

# User alias specification

# Cmnd alias specification

# Defaults specification

# Reset environment by default

#Defaults   env_reset

# Uncomment to allow people in group wheel to export variables

Defaults:%wheel   !env_reset

Defaults:%wheel env_keep="DISPLAY"

# Allow people in group users to export specific variables

# Defaults:%users   env_keep=TZ

# Runas alias specification

# *** REMEMBER ***************************************************

# * GIVING SUDO ACCESS TO USERS ALLOWS THEM TO RUN THE SPECIFIED *

# * COMMANDS WITH ELEVATED PRIVILEGES.                           *

# *                                                              *

# * ONLY PERMIT SUDO ACCESS SPARINGLY, AND NEVER ALLOW ACCESS TO *

# * UNTRUSTED USERS.                                             *

# ****************************************************************

# User privilege specification

root   ALL=(ALL) ALL

# Uncomment to allow people in group wheel to run all commands

%wheel   ALL=(ALL)   ALL

# Same thing without a password

# %wheel   ALL=(ALL)   NOPASSWD: ALL

# Samples

# %users  ALL=/sbin/mount /cdrom,/sbin/umount /cdrom

# %users  localhost=/sbin/shutdown -h now

%users   ALL=/usr/sbin/hibernate   NOPASSWD

```

The user that I have been using is a member of the wheel group. I also have exported XAUTHORITY="${HOME}/.Xauthority" in /etc/profile. If I set display to :0.0, I am able to connect. In my past experience, the package sux works, but I cannot believe that I am having so many problems with sudo su - and $DISPLAY.

I do not mean to be rude, but I really do not want to have to crutch on anything that is unsafe such as using 'xhost +*' or just use 'su.'

Are there any straight answers here?

----------

## Dlareh

First of all sudo su - is completely redundant.

Use

```
sudo -s
```

Or

```
su     # optionally, su -
```

To preserve $DISPLAY, try using this instead of su:

```
sux
```

Given your !env_reset in sudoers, sudo should be preserving DISPLAY already.  It is your pointless redundant use of su that is botching this.

----------

