Skip to content

One time file transfer with nc command



Transferring files between systems is a common task in the world of computing. There are several ways to transfer files, but one of the most popular and easiest methods is through the nc (netcat) command. In this blog post, we will discuss how to transfer files using nc command in Linux.


I. First, use nc to listen on port 6543 on the receiver and redirect all received content to a file (out.file).

nc -lvp 6543 > out.file


II. On the sender, send the file to the port of the receiver machine.

nc -q 1 ip 6543 < in.file

To exit automatically, add the -q option.

-q seconds   after EOF on stdin, wait the specified number of seconds
             and then quit. If seconds is negative, wait forever.

  • Welcome to visit the knowledge base of SRE and DevOps!
  • License under CC BY-NC 4.0
  • Made with Material for MkDocs and improve writing by generative AI tools
  • Copyright issue feedback, replace # with @