• User-uploading of files is now fully enabled!! Check out our full announcement for details.

    All accounts with 0 posts on them have been purged. If you are coming back to us after a long time and you find you can't log in, then that would probably be why.

Info How to Set Up Very Simple File Sharing on Linux

For any threads that are not purely stories, opinions, or questions. Threads with purely information found on any wiki are not allowed either!

Arnox

Master
Staff member
Founder
Messages
6,144
I honestly can't believe I didn't hear about this before and feel a bit stupid. One should keep in mind though that this is a ONE WAY share. There is ZERO uploading to the file hosting machine. There is also no verification whatsoever. Anyone can access and download files from the file hosting machine if they know the right port. And finally, if there is a shortcut/symbolic link in the directory you serve up, the user can follow that shortcut into another directory you may not have wanted available at all.

First, get your hosting machine's local IP address. (Starts with 192.168.) If you're planning to reach the file hosting machine over the internet (not recommended due to security concerns), you'll need your public-facing IP. Next, open up a terminal, navigate to whatever folder/directory you want to share files from using the 'cd' command and simply type this in:

Code:
sudo python3 -m http.server 80

The "80" is the port number the file hosting machine will accept requests from. You can change it to any other port you want. Now, using any other computer or smartphone, in any browser, type in the hosting machine's public-facing IP address (if accessing the file hosting machine on a LAN, type in the local IP address) and then a ':' and then the port number the file hosting machine is accepting connections on that you specified earlier. If it was 80 though, then you shouldn't need to specify the port number. So, say I have the file hosting machine with an local IP address of 192.168.1.9 accepting connections on port 2000. I'll type the following into my browser.

Code:
192.168.1.9:2000

This will bring up a dead-ass simple file listing for the folder you chose to open up for downloading. Just click on what you want to download it.

A quick warning though. Many distros now use and enable Uncomplicated Firewall or UFW by default, and if that is so, you'll have to disable it first or else trying to connect to the file hosting machine will just net you a "Connection timed-out" error. To do that, just type in the following before trying to connect to the file hosting machine:

Code:
sudo ufw disable

And then when you're done,

Code:
sudo ufw enable

When the Python 3 HTTP server is active, you can make it exit by simply pressing Ctrl+C. Alternatively, you can just exit out of the terminal window it's running in.

If you need something with more features than this, you should probably look into employing an FTP server instead.
 
Last edited:
Back
Top