Quick File Sharing for Linux and Mac OS X
Monday, March 1st, 2010This is a great little trick to quickly make a directory of files accessible to anyone. You can do it in any OS that has Python installed, which most Linux distros and Mac OS X do. Windows does not have python installed by default, but the same thing should work from there if python is installed.
First, open the terminal and navigate to the directory you want to share. While in that directory type the following command:
-
python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"
This will start a web server on port 8000. This is a very simple and quick way to share a file over the network. Just send a link to the IP address of the machine.
If you are behind a NAT router or firewall, port 8000 needs to be forwarded or opened, but if you are on the same network all you need to do is send them a link to http://<your_ip_address>:8000 and they can easily browse the directory you ran the command from and download any file there. When you're finished, go back to the terminal and use Ctrl+C to end the process.


I wish I had a dollar for every time I've needed to lug a computer monitor out from its usual location and sit it on the floor, plug it into the wall and a headless computer. I have a 700MHz Pentium 3 in the living room hooked up to the television working as a media hub. I also have a slower machine working as a print/scanner server and web server. Every so often something goes screwy and I can't log into one of them over the network. I have thought time and time again that what I really need is a way to hook these boxes up to my laptop and use the keyboard, touchpad, and LCD screen to control and get feedback from the headless systems. I have thought about this but never realized that this was really possible. Well, as it turns out, it is possible!