Cinan's world

GNU/Linux & free software, howtos, web development, scripts and other geek stuff

Unix Beauty – Copy & Paste Between Machines

Redirecting standard output and using it to put that output to a file is well-known and easy. Almost that easily any output can be redirected from one machine to another one. Say hello to nc utility.

nc is part of netcat package which comes in two flavors in most of Linux distributions: nc-traditional and nc-openbsd. In examples below I use -traditional.

On the first machine start listening on some port:

1
$ nc -lp 12345 > ~/file_received

Then, on another machine run something like this:

1
$ cat send_file | nc <hostname> 12345

That’s all. First machine starts listening on port 12345 and another machine sends stream of data to that port. The communication isn’t encrypted so for transmitting sensitive data use scp.

Comments