HostOnNet Blog

Quickly Sharing Files On Ubuntu

Looking for Linux Server Admin or WordPress Expert? We can help.

Ubuntu used to have a public folder, that you can share using Samba. Recent versions of Ubuntu do not include Samba by default, you can install it if you need to share files regularly with other computers on network.

https://www.samba.org/

Samba will allow share files between Linux and Windows as it use Windows SMB/CIFS protocol.

If you just need to share few files with others on same network (LAN), you can do with python command. Python is already installed on all Linux computers, so you don’t have to install anything. Just change to the directory and run

python -m SimpleHTTPServer

For example, you need to share your download folder, run

cd ~/Downloads
python -m SimpleHTTPServer
boby@fwhlin:~ $ cd ~/Downloads/
boby@fwhlin:~/Downloads $ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
192.168.1.2 - - [21/Jul/2015 21:57:25] "GET / HTTP/1.1" 200 -
192.168.1.2 - - [21/Jul/2015 21:57:26] code 404, message File not found
192.168.1.2 - - [21/Jul/2015 21:57:26] "GET /favicon.ico HTTP/1.1" 404 -

A web server will be started on port 8000 and bind to all IP available on your PC.

Others on LAN can now access your shared files by browsing to URL

http://YOUR-IP-ADDR:8000

To run on different port, run

python -m SimpleHTTPServer PORT_HERE

For example

sudo python -m SimpleHTTPServer 80

We used sudo as port 80 is privileged port, only root can listen on this port for security reason.

Posted in Python

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.