Skip to content

One time file transfer with nc command

homepage-banner

Introduction

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.

Receiver

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

Sender

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.
Leave a message