ubuntu で root 時に cannot open display となる件

ubuntu 9.04 を使っているのですが、su で root になって synaptic や firefox などを起動しようとしたときに、cannot open display と言われて起動できないことがありました。

% su -
パスワード:
# firefox
Error: no display specified
# synaptic

(synaptic:4565): Gtk-WARNING **: cannot open display:

これは、root の環境変数 DISPLAY の値をログインユーザの DISPLAY 値と同じにすると O.K. です ;)

ログインユーザの DISPLAY 値を確認

% echo $DISPLAY
:0.0

root の DISPLAY 値に先ほどログインユーザで確認した DISPLAY 値を指定

# export DISPLAY=:0.0