nc flags & options

-l

Listen for incoming connections.

nc -l 8080

-p

Specify the source port.

nc -l -p 4444

-v

Enable verbose output.

nc -v example.com 80

-z

Scan for open ports without sending data.

nc -zv example.com 20-80
nc -zv example.com 443

-u

Use UDP instead of TCP.

nc -u example.com 53
nc -lu 5000

-w

Set a timeout in seconds for connections.

nc -w 5 example.com 80

-k

Keep listening after a client disconnects.

nc -lk 8080

-e

Execute a program on connection (where available).

nc -l -p 4444 -e /bin/sh

Common patterns

Transfer a file over the network.

nc -l 9000 > received_file
nc host 9000 < local_file