How to Download Torrents from the Command Line in Ubuntu

A photograph of a laptop on top of a bed.

While torrenting doesn’t have the best reputation, there are still a lot of positives to using it. For starters, if you want to share a file, it’s a great way to outsource your bandwidth. No more hosting download servers. Just give a torrent out to your community, and have them seed the torrent! Low bandwidth bills and fast transfers for everyone!

For the most part, torrenting on Linux is done through graphical clients. However, you might be interested to know that it is also possible to torrent directly inside the terminal. This article will show you how to download torrents in the latest Ubuntu LTS.

Installing a CLI Torrent Client on Ubuntu

There are many good CLI-based torrent clients, but few are as good as transmission-cli. It is the easiest to use out of all the choices out there and similar to the most-used torrent client on Linux (Transmission).

To install transmission-cli, open a terminal window and enter the following command:

sudo apt install transmission-cli

FYI: learn some of the best free software in Linux today.

Adding a Torrent in Transmission

Adding a torrent to transmission-cli is pretty straightforward. Start by finding a torrent file from your preferred torrent distributor. In this tutorial, we’ll be using the Ubuntu MATE LTS release torrents.

Downloading a Torrent Using a URL

Transmission CLI can download torrents directly from a URL by doing:

transmission-cli https://cdimage.ubuntu.com/ubuntu-mate/releases/22.04/release/ubuntu-mate-22.04.3-desktop-amd64.iso.torrent -w ~/Downloads
A terminal showing Transmission CLI running with a custom download directory.

This method is great if the user is in a pinch and just wants the download to happen as soon as possible.

Downloading a Torrent Using Magnet Links

The Transmission CLI torrent client also has support for magnet links. To download a torrent with a magnet link, try something like this:

transmission-cli magnet:?xt=urn:btih:0223dcb7785d09dbdff5839a089774277a66b4c9&dn=ubuntu-mate-22.04.3-desktop-amd64.iso -w ~/Downloads

Downloading a Torrent Using Torrent Files

And lastly, Transmission CLI can start a download through a local torrent file. Obtain a torrent file by conventional means (through a web browser) or find a link to a torrent file, and download it through the terminal with wget.

For example:

wget https://cdimage.ubuntu.com/ubuntu-mate/releases/22.04/release/ubuntu-mate-22.04.3-desktop-amd64.iso.torrent

To download with a torrent file, do the following:

transmission-cli ./ubuntu-mate-22.04.3-desktop-amd64.iso.torrent -w ~/Downloads

Enabling a Peer Blocklist

Since transmission-cli works different than its graphical counterpart, it often doesn’t save its settings. This means that you need to specify your peer blocklists every time you download torrents in Ubuntu. The -b flag enables a blocklist. To use one while downloading, follow this example:

transmission-cli https://cdimage.ubuntu.com/ubuntu-mate/releases/22.04/release/ubuntu-mate-22.04.3-desktop-amd64.iso.torrent -w ~/Downloads -b https://mirror.codebucket.de/transmission/blocklist.p2p.gz
A terminal showing Transmission CLI downloading a torrent file with a custom blocklist.

Downloading Torrents with Encryption

Though it’s not recommended to download sketchy files from torrents, it happens. To protect yourself while downloading these types of files, it is possible to encrypt the traffic while you download torrents in Ubuntu. Here’s how to do it:

transmission-cli https://cdimage.ubuntu.com/ubuntu-mate/releases/22.04/release/ubuntu-mate-22.04.3-desktop-amd64.iso.torrent -w ~/Downloads -er

The -er flag tells transmission-cli that it requires encryption with all peers that it connects to. This may slow down transfer speeds, so this option might not be for everyone, especially those on a slow connection.

To download with encrypted traffic, but also increase your transfer speed, try using the -ep flag instead. This will tell peers that the client would prefer encryption, but it won’t require it.

transmission-cli https://cdimage.ubuntu.com/ubuntu-mate/releases/22.04/release/ubuntu-mate-22.04.3-desktop-amd64.iso.torrent -w ~/Downloads -ep
A terminal showing Transmission CLI downloading a torrent with the -ep flag on.

Good to know: learn how to secure your data in Linux by encrypting your local files using Tomb.

Exploring Other Transmission Flags

Transmission-cli is filled to the brim with all sorts of different options. To view these options, run transmission-cli --help. Doing so will print out different command modifiers and flags that users can add to their transmission-cli commands for a better downloading experience. For example, you can enter transmission-cli -d 800 to limit your client’s total throughput to 800 kilobytes per second.

A terminal showing the help screen for Transmission CLI.

Downloading Torrents Using rTorrent

Aside from Transmission CLI, you can also use other terminal torrent clients to manage your torrent downloads. These are often terminal-only tools which means that they contain features that are geared towards user automation and macros.

rTorrent is a popular TUI torrent client that allows you to automatically handle share ratio, TOR, and automatically scrape torrent files from websites. To install it in Ubuntu, run the following command:

sudo apt install rtorrent

To add a torrent file in rTorrent, open a new terminal session and run rtorrent. This will load the client’s TUI and take over the entire terminal screen.

A terminal showing rTorrent running on Ubuntu LTS.

Press Enter to open the torrent prompt, then type the path to your torrent file. This could either be a local “.torrent” file or a remote link.

A terminal highlighting the file prompt for rTorrent.

Press the Down Arrow key to select the first torrent file, then press Ctrl + S to start downloading your new torrent.

A terminal showing rTorrent actively downloading the Ubuntu MATE LTS torrent.

Downloading Torrents Using aria2c

Aria2c is a lightweight, and highly minimal download manager for Linux. Unlike Transmission and rTorrent, aria2c is a multi-protocol download client which means that you can also use it to download non-torrent files. You can obtain it by running the following command:

To download a torrent with aria2c, run the program followed by the path of the “.torrent” file that you want to download. Just like in rTorrent, this could either be a local or remote path:

aria2c https://cdimage.ubuntu.com/ubuntu-mate/releases/22.04/release/ubuntu-mate-22.04.3-desktop-amd64.iso.torrent

You can also download torrent files directly in aria2c using their magnet links:

aria2c magnet:?xt=urn:btih:0223dcb7785d09dbdff5839a089774277a66b4c9&dn=ubuntu-mate-22.04.3-desktop-amd64.iso

Though it doesn’t seem as glamorous to download with a command instead of a fancy GUI, you’d be wrong. For instance, Transmission CLI has more features than even most mainstream graphical clients. Meanwhile, rTorrent and aria2c also pose as great alternatives that provide unique features such as ratio handling and multi-protocol support.

Downloading torrent files is just one of the few things that you can do inside your terminal. Learn how you can create custom prompts for your terminal using Starship.

Image credit: Jay Wennington via Unsplash and Wikimedia Commons. All alterations and screenshots by Ramces Red.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Ramces Red

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.

Leave a Reply

Your email address will not be published. Required fields are marked *