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

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

Show File Transfer Progress With Rsync

Show File Transfer Progress With Rsync

When you are transferring a large number of files that take some time, the rsync command shows a blank output.

The cursor just blinks without any information.

This leaves you wondering whether the files are being transferred or its just trying to connect to the remote server.

The good thing is that rsync is a versatile tool and it allows to show the status of file transfers.

Just add --progress to your rsync command and it starts showing the files being transferred:

rsync -r --progress source destination

There is no specific location for the --progress option. You can even add it to the end of the rsync command.

Show File Transfer Progress With Rsync

You also get to see a summary of files transferred along with the transfer speed and time.

You can also use -P option instead of --progress. It’s the shorter form for the same.

Show overall progress with rsync

This is all good. But if you have hundreds of files to transfer, it gets messy. The entire screen is filled with the file transfer statistics. You may not always want that.

Good thing again! You can make rsync show the overall progress instead of showing it for each individual file.

Instead of --progress option, use info=progress2 option.

rsync -r --info=progress2 source destination

Here, you control the information to be displayed with the info option. You tell it to show the information for the progress i.e. file transfer.

Some flags, like progress, are followed by a number. 0 means to silence the output, 1 means to show it for each file and 2 means total transfer progress.

Show File Transfer Progress With Rsync

This way, you get to see the overall progress of the files being transferred with rsync. This is a much cleaner output. Your screen is not flooded and you can easily understand the output.

Once the rsync command finishes the file transfer, you also get to see the summary of average transfer speed and time spent.

Show File Transfer Progress With Rsync

That’s super cool, isn’t it? You now know how to display the file transfer progress with rsync command.

This is just one of the many cool things this handy CLI tool can do. Read this for more practical examples of the rsync command.