ANNOUNCEMENT: Live Wireshark University & Allegro Packets online APAC Wireshark Training Session
April 17th, 2024 | 14:30-16:00 SGT (UTC+8) | Online

Wireshark-users: Re: [Wireshark-users] (wireshark:26800): Gtk-WARNING **: cannot open display:

From: Stephen Fisher <stephentfisher@xxxxxxxxx>
Date: Tue, 11 Dec 2007 23:21:32 -0700
On Wed, Dec 12, 2007 at 12:28:34AM -0500, Greg Toombs wrote:

> I'm running a shiny new installation of Gentoo, and wireshark *looked*
> like it compiled alright. And (although it has no icon) the menu entry
> for wireshark correctly starts it up in non-root mode, although
> non-root mode is pretty much useless.

The next version (yet to be released) has a ./configure option that lets
you run Wireshark as non-root while the capturing part runs a root :).

> First of all, wireshark didn't install a "run with gksudo" menu entry
> in XFCE, but that's not the biggest problem. When I run wireshark from
> the terminal it works, but when I run sudo wireshark I get

Wireshark doesn't install any window manager specific things at this
time other than providing a wireshark.desktop file.

> (wireshark:26800): Gtk-WARNING **: cannot open display:
> 
> When I run echo $DISPLAY it gives
> :0.0

sudo/su doesn't always carry your environment variables to the program
being run as root.  To verify this is happening, try sudo echo $DISPLAY
and verify it is blank.  If so, try adding the DISPLAY variable
assignment to your root shell's startup dot-file and see if that works. 
Your sudo may also have an option to preserve environment variables such
as DISPLAY when running.  I don't have a Linux machine handy at the
moment to try it out, but on MacOS X sudo does preserve environment
variables and has an option not to.


Steve