Skip to Content
Author's profile photo Juan de la Cruz Arellano Royo

Redirect xWindow display

Some times we haven’t access with root user directly to a server and we need execute su – to scale up to root. When we do we lose X connection but we can perform the following steps to run applications XWindow:

1.- Connect to server and list enviroment variables and xauth

Connecting to…

Connection established.

To escape to local shell, press ‘Ctrl+Alt+]’.

Last login: Mon May 23 11:22:22 2016 from

johnd@JohnD-Server1:~> echo $DISPLAY


johnd@JohnD-Server1:~> xauth list $DISPLAY

JohnD-Server1/unix:10  MIT-MAGIC-COOKIE-1  70a56a2cb6e8d74cfefc29c1b6186efb

2.- Change to root user:

johnd@JohnD-Server1:~> sudo su –

3.- Set the variable and xauth

JohnD-Server1:~ # export DISPLAY=localhost:10.0

JohnD-Server1:~ # xauth add JohnD-Server1/unix:10 MIT-MAGIC-COOKIE-1 70a56a2cb6e8d74cfefc29c1b6186efb

Enjoy it

Juan de la Cruz Arellano Royo

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Nelis Lamprecht
      Nelis Lamprecht

      Just a tip for the above post. You can also use the following command as root to add the "magic cookie" from a X user:

      xauth merge ~user/.Xauthority

      Less work 😉



      Author's profile photo Juan de la Cruz Arellano Royo
      Juan de la Cruz Arellano Royo
      Blog Post Author

      Thank you very much for your reply


      Juan de la Cruz Arellano Royo