Simple way to transmit files over network (nc utility)

There are many ways to transmit files between computers over the heterogeneous network (Linux, Windows, Apple MAC and other systems). I used to run SCP for my every day administrative tasks, especially when client SCP utility is available for Windows too.

But here is useful tip on how to transmit files over network with no need to install and configure any service at server: just run at Linux or Unix server simple command:

nc -l -p 12345 < /etc/apache/httpd.conf

After this file /etc/apache/httpd.conf will be available at 12345 TCP port at any server’s IP address. To get it just load http://192.168.0.7:12345 with any browser you like (192.168.0.7 is server’s IP) at client’s PC. After file is downloaded it’s impossible to download it again without restarting nc command. Here are the results of my example:

nc-terminal.png

nc

Theoretically it shouldn’t work as there are no web server headers like Content-type or Status. But it works. Ideas why it’s so are highly appreciated :)

You might also be interested in:
Web server on bash (in one line!)

 
 
» You might also be interested in the following articles:
Encryption files with GPG without user intervention (batch)
Manage gzip files on-the-fly (zcommands)
The easiest way to split and merge pdf files in Ubuntu
radiotray: online radio player for Ubuntu
FAQ: static routes after restart/reboot in Fedora/RedHat/CentOS



» Want to stay up to date? Subscribe to our E-MAIL or RSS feed!

2 Responses to “Simple way to transmit files over network (nc utility)”


  1. 1 TheWorm

    I think that those headers are just directive for our browsers. The browser show everything it receive, except headers, and you have written it plain text.

  2. 2 Mark

    After this file /etc/apache/httpd.conf will be available at 12345 TCP port at any server’s IP address. To get it just load http://192.168.0.7:12345 with any browser you like (192.168.0.7 is server’s IP) at client’s PC. After file is downloaded it’s impossible to download it again without restarting nc command. Here are the results of my example:
    +1

Leave a Reply




Friendly Sites:Who is behind Linux Screw?
GeekyBits³ | Bash Cures Cancer | OMG! Ubuntu!
My SysAd Blog | Web Upd8
ZEPY | Linux config Wiki | Planet Sysadmin
a non-geek's linux notes | Linux Today
Linux HOWTOs, Tutorials & Projects with Adam Palmer | LinuxAlt.Com
My name is Artem N. (artiomix AT gmail DOT com) and I'm Linux/Unix, Cisco systems engineer. The main idea of Linux Screw is to share relevant knowledge, skills and observations over The Web. Here you can find a lot of information related to different Linux distributions, FreeBSD, IOS as well as a other Open Source around staff. Read more ››