466cbcc4 |
---
layout: post
title: "Unix beauty – copy & paste between machines"
date: 2014-03-30 23:18
comments: true
categories: [server, shell]
cover: /images/cover/avatar.png
keywords: clipboard, send file, linux, server, remote
description: Send data between computers remotely
---
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:
{% codeblock lang:bash %}
$ nc -lp 12345 > ~/file_received
{% endcodeblock %}
Then, on another machine run something like this:
{% codeblock lang:bash %}
$ cat send_file | nc <hostname> 12345
{% endcodeblock %}
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```. |