chatting and transfer file with netcat

February 28th, 2007 mysurface Posted in Admin, nc | Hits: 73062 | 13 Comments »

netcat, or sometimes the command known as nc capable of doing a lots of thing. The examples of how to use nc to scan open ports showing here.

Here, using netcat to initiate a private chat, we need a listener server with open port and a client connect to the listener server.

Listener: (IP:

nc -l 5678

-l is listen, -p is to specify port.


nc 5678

Okay, both side can start chatting.

The same way for file transfer. Let say listener server as a file receiver and client as a sender.

Listener: (Receiver)

nc -vv -l 5678 > dump.mp3

-vv is make the transaction very verbose, so that you will know what is happening.

Client: (Sender)

nc 5678 < dump.mp3

File transfer using nc usually fast, because it do not do encryption/decryption over the communication. It is good for transfer file from point to point or in LAN. You can do it over internet but you need to make sure you have do port forwarding on the listener port.

13 Responses to “chatting and transfer file with netcat”

  1. for the above examples to work on all systems it might be necessary to first do a ln -s /usr/bin/netcat /usr/bin/nc because afaik on systems like opensuse the binary is called netcat and not nc

  2. why would someone want to make a link, just replace netcat with nc and viseversa.

  3. Why would you create a link OR replace the files.

    Just create an alias!

  4. man page of nc says “It is an error to use -p option in conjunction with the -l option”. so in my case, the worked solution was:

    cat filename | nc -l 3333 (on server, file sender)
    nc 3333 > filename (on client, file receiver)

  5. @kamran, I think when I wrote this post, I am using the older version of nc, which that needs -l and -p. By the way, thanks for raising this up, let me amend my post.

  6. thnx kamran that was helpful!

  7. @mysurface, i think there is some conflict. different distributions giving different versions (or may be different falvors) of netcat. the solution i proposed in a previous comment worked for me in fedora 9, and fedora 10. but now i have switched to PCLinuxOS and this solution no longer works. so i tried your solution and it worked.

  8. Hello mate. I am still very new in blogging and all aspects around this industry. There are lods of terms I still don’t know. I’m not really sure I can write half decent to yours. I am gonna read the entire site perhaps I can grasp your blogging style a little.

  9. super acest lucru este minunat am gasit ceva la fel
    aici la WZY :) imi place

  10. Pay per click PPC gives you the distinctive web crawler
    edge of staying ahead of the competition.
    Yahoo Directory – General 2. A – To decide which advertising copy will have a lonely life because it won’t.
    How to choose great keywords for your website to
    warranty high ranking, and then they go for Report status that includes Search engine
    ranking reports, Monthly work status reports,
    Client support and traffic status reports.

  11. Attractive element of content. I simply stumbled upon your website and in accession capital to
    claim that I get in fact loved account your blog posts.
    Anyway I will be subscribing in your augment and even I success you get right of entry to consistently

  12. Thanks designed for sharing such a fastidious thought, post is fastidious, thats why i have read
    it completely

  13. I’m no longer certain where you’re getting your information, but good topic.
    I needs to spend some time finding out more or understanding more.

    Thanks for wonderful info I was searching for this info for my

Leave a Reply