Sending File From One Linux Machine to Another Machine
Date January,22 2012 @ 19:05
I had some files which need to be sent a file from one Linux machine to another. Till that time my usual approach would be to download the file to my local desktop from first Linux machine then again upload it to second machine. But recently I came to know about “nc” command which open a raw TCP/IP socket from one machine. We can use this command to send data from one machine to another directly.
- Set receiving computer in listening mode.
nc –l 9999 > abc.tarThis command will open a client socket on the current machine(say Target Machine) on port 9999 and listen on it. Whenever some program sends data on this port, it will dump those data to abc.tar file.
- Send file from the sender computer
tar -cvpz <file or folder> | nc 9999This command will open a TCP/IP connection to , tar the file and send the raw stream to target machine on port 9999 This is much simpler and quicker way to transfer any file from one machine to another machine. There are many ways to use nc command some of them are listed here.
