File Transfer
Netcat can transfer files between systems by treating the network connection as a simple data pipeline. One system listens while the other connects and sends data.
Basic File Transfer
To transfer a file, set up a listener on the receiving system, then connect from the sending system and redirect the file as input.
Receiver (Listening)
On the system that will receive the file:
Listens on port 4444 and saves all received data to received_file.txt
Sender (Connecting)
On the system that has the file to send:
Connects to the receiver and sends secret_document.pdf as input
Receiving Compressed Archives
You can combine Netcat with compression tools for efficient transfer of large files or directories.
Transfer a Directory
Using tar to package and compress a directory before transfer:
Transfer with Progress Monitoring
Using pv (pipe viewer) to monitor transfer progress:
Bidirectional Communication
Netcat can also facilitate two-way communication for simple chat or command execution:
Simple Chat Setup
Two systems can chat by each listening on a port and connecting to the other:
Each system types messages that appear on the other's screen