Search code examples
wireshark

Error "cannot open display" when starting wireshark on Ubuntu command line


I have installed wireshark on Ubuntu, When I run it:

/usr/bin/wireshark

I get an error:

(wireshark:27945): Gtk-WARNING **: cannot open display:

I want to run wireshark on the command prompt.

I don't want to use the UI. I'm not sure why it is complaining about a display, I want to run it on a port.


Solution

  • You can try tshark - which is a "console based wireshark" which is part of wireshark project.

    You should read Read man tshark.

    For example to capture http packet on 80 port run:

    tshark -f 'tcp port 80 and http'
    

    P.S. Example was fixed to use capture filter instead of display filter.