Stupid Easy Way to Transfer Small Files to or from Ubuntu 22.04

Last updated: January 22, 2023 — 3 Comments

There are quite a few ways to transfer files between different machines. For Ubuntu and most other Linux, here’s an easy way for choice.

Usually, I use a USB cable or a messenger app for transferring photo images between my personal PC and mobile devices.

However, my USB cable is always NOT near at hand and I hate to scan QR code again and again on PC for logging 3rd app. In this case, creating a temporary http file server with Python is an easy and good choice.

Upside and downside

Python is pre-installed in most Linux Distros. So this is an universal method for Linux. It also works in Windows and macOS with Python programming language installed.

As a simply http server, any devices with a web browser can download (or upload) files from/to the server side either over local network or internet.

However, http is NOT designed for transferring files. It’s OK to handle small files (e.g., photo images and short videos less than a few hundred MB). But for large files with a few GB or more file size, it may not work! As well, it’s NOT secure for accessing important files outside from local network.

Single command to create a Python http server:

For those who are new to Linux, user may first open file manager, navigate to the folder that contains the files to share with other device, right-click on blank area and select “Open in Terminal”.

It will open a terminal window and automatically navigate to that folder as working directory.

Or, you can also open terminal from start menu and run cd command to navigate directory. For example, run the command below to navigate to user’s Pictures folder:

cd ~/Pictures

Then, run the single command to start a http file server (For some Linux, replace python3 with python in command):

python3 -m http.server

By default, it listens to port 8000. If the port is already in use, use python3 -m http.server 9090 to set another port number (change number 9090 as you want).

After that, visit http://ip-address:8000 (change number 8000 if you set another port) in any device via a web browser. You can then open and/or right-click save as to download any file from that folder.

Create python http server with upload support

1. If you want to send files from any device to Ubuntu Linux, open terminal and run command:

python3 -m pip install --user uploadserver

Install pip first via sudo apt install python3-pip if the command above does not work. This command will install a Python module uploadserver.

2. Then open or navigate to your desired folder in terminal window, and run command to create simple http file server with both download and upload support:

python3 -m uploadserver

Also specify port number if you want, for example, python3 -m uploadserver 9990

3. Finally, visit http://ip-address:8000 in any device via web browser can access and download files. Or, go to http://ip-address:8000/upload for uploading files.

For security reason, you may add a token authentication so client machines need to verify before being able to upload a file. To do so, run the command below instead in Ubuntu Linux:

python3 -m uploadserver -t password_here

Twitter

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via ubuntuhandbook1@gmail.com Buy me a coffee: https://ko-fi.com/ubuntuhandbook1

3 responses to Stupid Easy Way to Transfer Small Files to or from Ubuntu 22.04

  1. I pretty much stick to a USB drive to transfer files, it takes a bit longer to write the files twice, but a USB drive is easy to carry in the watch pocket of my jeans so I always have it.

  2. I use the same.

    You can also install an ftp server on your phone.

    “Tiny FTP Server” seems to not collect information

Leave a Reply

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

*