7

I know I can install Samba or openssh-server to be able to share files between two Ubuntu computers. Is there a way to share files without installing additional packages?

I installed Ubuntu on two systems on the same LAN, but without Internet connectivity. I found that my usual way of transferring files (scp) failed because openssh-server was not installed on either system. Using Personal File Sharing was impossible without installing extra packages. I ended up using netcat to transfer, which is suboptimal and not intuitive for the average user.

So I'd like to know if anyone knows of a way to do this with out-of-the-box Ubuntu installations (or at least, with packages available in the Ubuntu desktop CD).

Thanks!

19

You can move to a given directory with cd, then serve the current directory as a web server with the command:

python -m SimpleHTTPServer

On the other machine go to the address http://server-ip:8000/

where "server-ip" is what you see when you do "ifconfig" on the source computer, under "inet addr:". For example, if the output of ifconfig on the source computer starts like this:

eth0      Link encap:Ethernet  HWaddr 00:30:67:d5:a7:a4  
          inet addr:10.0.0.3  Bcast:10.0.0.255  Mask:255.255.255.0
          ...

then on the target computer, you should point the browser to:

 http://10.0.0.3:8000/
  • 1
    Thanks for this! I found this the easiest way to do what I need, just open a terminal, type a relatively simple command, and I can use the browser on the other system. – roadmr Jan 15 '12 at 20:12
  • thanks, this is the most easiest way to download files from other computers. Is there a way to speed up the transfer rate, currently i am getting only 2.5 MB/sec. – Ankit Aug 19 '12 at 4:35
  • 5
    Beware that in Python 3 SimpleHTTPServer has been renamed to http.server. – asmeurer Oct 15 '15 at 0:55
1

if you want something faster that python's SimpleHTTPServer module (which is awesome and is most simple way imho), you can use netcat (nc utility) - it's using raw TCP so you won't be having overhead that comes with HTTP protocol.

For example if you are trying to copy file config.xml from host germany.local to host france.local (both running ubuntu), you need to follow these steps:

  1. on target host france.local run:

    nc -l -p 7000 > copied_config.xml
    

    (it will start nc process that listens on the port 7000 for incoming data and writes said data to file copied_config.xml)

  2. on source host germany.local run:

    nc -q 0 france.local 7000 < config.xml
    

That's all!

Also, you can check this helpful howto for more in depth instructions

  • Thanks! If you read the question you'll notice it's what I did back then, and my comment was that it's suboptimal and not intuitive for the average user. I still prefer SimpleHTTPServer as it implies one command on the sending end and a browser on the "client" end which is super easy to use. – roadmr Oct 14 '15 at 17:48

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.