How to Setup A Basic File server Using simpleHTTPserver
Today, I am going to show you a cool trick that I just came across. It is how to turn your desktop system into a local file server in minutes using simpleHTTPserver. Yes, you can access your data on your harddisk can be accessed via a web browser. Anyone, even a novice user, can do this within a minute. simpleHTTPserver is a python module that can be used to setup a file server or serve a directory instantly in LAN. Anyone in the local area network can instantly access the folder or files from your system.
This brief tutorial describes how to setup a basic file server in minutes using simpleHTTPserver in Linux. This steps should work on any operating systems that supports python.
You know how to install Python. It is available in the default repositories of almost all modern Linux operating systems.
On Arch Linux and its derivatives:
$ sudo pacman -S python
On Debian/Ubuntu and its derivatives, run the following command from the Terminal:
$ sudo apt-get install python
$ sudo yum install python
$ sudo dnf install python
$ sudo zypper in python
After installing Python, you need to do one more thing. Just run the following command from your Terminal to start the file server:
$ python -m SimpleHTTPServer
For python 3.0 and above versions, run:
$ python -m http.server 8000
Sample output would be:
Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ..
To stop the file server, just press CTRL+C.
To find Python version, run the following command:
$ python -V
That’s it. File server is ready. Open the web browser and point it to http://IP-Address:8000
In case the port 8000 is blocked in your firewall, you have to open it.
For example, on RHEL/CentOS/Fedora, open port 8000 as shown below.
# firewall-cmd --permanent --add-port=8000/tcp
# firewall-cmd --reload
On Debian, Ubuntu you can allow the port as shown below.
$ sudo ufw allow 8000
Here it is how my local server’s contents looks in my browser.
Now, anyone in your local network can access your File server and it’s contents. Just set the permissions to your files and folders of your choice. You can then browse the contents from any local or remote systems as the way you do in any file server or website.
This is not full-fledged and secured file server. Python simply allow you to access your desktop/server contents via a web browser. This method is not recommended for production use. Use it within closed networks and home. Also, don’t forget to set proper permissions to avoid data loss and misuse.
Thanks for stopping by!
Help us to help you:
- Subscribe to our Email Newsletter : Sign Up Now
- Support OSTechNix : Donate Via PayPal
- Download free E-Books and Videos : OSTechNix on TradePub
- Connect with us: Facebook | Twitter | Google Plus | LinkedIn | RSS feeds
Have a Good day!!