Python has a built-in module to quickly start a simple HTTP server. To run it, use the command:
For Python 3.x version:
# python3 -m http.server
For Python 2.x:
python -m SimpleHTTPServer
By default, this will start an HTTP server on port 8000. This HTTP server will share the contents of the current directory.
Most often, I use this method to quickly get files from a Linux host to another device. For example, I need to download a specific log file from the /var/log directory.
To do this, go to the specified directory:
$ cd /var/log
And start the python HTTP server:
$ python3 -m http.server 8080
If this port is blocked by a firewall, you must first temporarily open it:
$ sudo firewall-cmd --add-port=8080/tcp
Or in Ubuntu:
$ sudo ufw allow 8080
Now open a browser on another device, go to URL
http://192.168.79.128:8080, and download the necessary files.
The HTTP server writes logs of all HTTP GET queries to the console.
Then return to the Linux console and stop the python web server process by pressing
This trick can also be used to transfer files from WSL to Windows.