Skip to content

Instantly share code, notes, and snippets.

@nepsilon
Last active February 19, 2017 12:38
Show Gist options
  • Save nepsilon/ff18984be21f3c49be9b to your computer and use it in GitHub Desktop.
Save nepsilon/ff18984be21f3c49be9b to your computer and use it in GitHub Desktop.
An intro to netcat — First published in fullweb.io issue #13

An intro to netcat

Ever heard of netcat? It’s a small network utility to create TCP and UDP connections.

Simple file transfer over network:

# Run the server with:
$ nc -l 8000 > file_you_receive

# Send the file on the client with:
$ cat file_you_send | nc server_ip 8000

Getting fancy, transferring lots of small/medium files efficiently:

$ tar -cf - . | pigz | nc -l 8000

# On the receiving machine:
nc server_ip 8000 > all_your_files.tar.gz

pigz is a parallel gzip.

By default netcat uses TCP, use UDP with -u:

netcat -u -l 8000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment