Transfer Files Using Netcat

nc is an excellent command line tool available on *nix systems. One of the quick tips is using it to transfer from one machine to another. Assuming your receiving machine is at 10.0.0.2 and your sending machine is 10.0.0.3, we can use the following to stream it using a socket (using 1337 as an arbitrarily chosen yet available port).

# on receiving machine
nc -l 1337 > my-large-file.sql

# on sending machine
nc 10.0.02 1337 < my-large-file.sql

Likewise, we can actually flip this in case it's easier to tell a co-worker to execute the command after you have a stream ready to send the file.

# on sending machine
nc -l 1337 < my-large-file.sql

# on receiving machine
nc 10.0.0.3 1337 > my-large-file.sql
Author image

R. Christian Di Lorenzo

I'm a Data Science grad student and software engineer for Web and iOS. I craft unique and innovative software experiences to improve fellow humans' lives as I live for Christ.
  • North Carolina, U.S.