BPF filter syntax is its own small language. Pick what you want to see and get a capture command that records it without filling the disk.
Running tcpdump over SSH without excluding port 22 captures the packets carrying its own output, which generates more output, which generates more packets. The capture becomes useless and the session may stall. Always add not port 22 when working remotely. Two other habits worth forming: -nn stops tcpdump doing DNS lookups for every address, which is both slow and generates traffic that pollutes the capture, and capture filters are far cheaper than filtering afterwards because the kernel drops non-matching packets before they are ever copied.
This tcpdump builder generates capture commands with BPF filter expressions for protocol, host, direction, and port, combined correctly with and, or, and not. It adds the flags that make captures usable: -nn to skip name resolution, -s 0 for full packets, -c to stop after a count, -w to write a file for Wireshark, and the -C and -W rotation options that stop a long capture filling the disk.
A capture filter uses BPF syntax and decides what tcpdump records; anything it excludes is gone forever. A display filter is Wireshark syntax and only decides what you see from data already captured. They are different languages, which is why a Wireshark filter pasted into tcpdump fails.
Capturing on any works but does not support promiscuous mode and can behave differently with VLAN tags and some tunnels. If a specific interface shows traffic and any does not, name the interface explicitly. tcpdump -D lists what is available.
Yes, pcap is the shared format. Capture with -w on the server where the traffic is, copy the file, and open it locally. You can also pipe a live remote capture straight into Wireshark over SSH, which the generated commands include.
Packet capture needs elevated privileges, but running the tool as root is avoidable. Grant CAP_NET_RAW and CAP_NET_ADMIN to the binary, or use dumpcap and add yourself to the wireshark group. This matters because packet parsers process hostile input and have a long CVE history.