debian root set display

it’s been a while since my last post …
here just a short solution of a problem i had with some debian boxes:

Problem:

emacs /etc/inetd.conf
Invalid MIT-MAGIC-COOKIE-1 keyemacs: Cannot connect to X server :0.0.
Check the DISPLAY environment variable or use `-d'.
Also use the `xhost' program to verify that it is set to permit
connections from your machine.

Solution:

cb0@localhost:~$ su -
root@localhost:~# xauth merge ~cb0/.Xauthority #replace cb0 with your username
root@localhost:~# export DISPLAY=:0.0
#now you are able to open emacs
root@localhost:~# emacs .bashrc