Python, which is included by default in most Linux distributions, provides simple HTTP servers through the “SimpleHTTPServer” and “http.server” modules. The former is found in the Python 2 Standard Library, while the latter is included in Python 3. These lightweight HTTP servers require no separate installation and can be started instantly with a single command.

Installing Python

Your system most likely includes at least one Python version, but if that’s not the case, install Python 3 using your native package manager. For example, on Debian and Ubuntu:

Starting the HTTP Server

Take note of the IP address used by the sending machine. Find out which Python version is installed with the following commands: On the same machine, change your working directory to the one containing the files you’re transferring. Be aware of the fact that the entire contents of your current working directory may be accessible to anyone on your network (or the Internet if the sending machine has a public IP address), while the Python HTTP server is running. For example: You can now start the HTTP server. For Python 2.x, use the SimpleHTTPServer module: Or http.server in the case of Python 3.x: Both variations listen on port 8000 by default, though you can explicitly specify a different port number after the module name. Note: root privileges are required if you choose a port under 1024.

Downloading Your Files

On the receiving machine, you can use any HTTP client to download your files. If you’re using a graphical environment, a browser is often more convenient than command line utilities. Simply browse to http://IP_ADDRESS:8000, where “IP_ADDRESS” is the IP address of the sending computer, and click on the desired files to download them. Alternatively, you can use Wget or cURL to fetch your files. You should already have one or both of them installed. If neither are, we suggest installing Wget, as it is more user friendly and supports downloading whole directories. For Debian and Ubuntu: For RHEL and CentOS 6/7: For Fedora and RHEL/CentOS 8:

Using Wget

To download a single file with Wget, simply invoke Wget followed by the URL of the file you want to download. You can also use Wget to recursively download the whole directory by adding the -r command-line flag.

Using cURL

By default, curl tries to print file contents to your terminal. So to save the file instead, specify a filename with the -o flag.

Conclusion

The HTTP functionality in Python’s standard library supplies a basic yet fast and convenient way of transferring files, perfect for some scenarios. But keep in mind that because this is plain HTTP with neither encryption nor authentication, you should be careful to not expose sensitive files.