How to download torrent from CLI in Ubuntu? [SOLVED]


Ubuntu

Author: Omer Cakmak
Reviewer: Deepak Prasad

What is a torrent file?

The word torrent is an expression used to name the metadata linked to the files and folders to be downloaded. A torrent file (.torrent) does not contain the actual file you downloaded, it contains an image of the original file on the server It is a fast and reliable system that allows users to download and share large data.

There are many torrent clients that work from both GUI and terminal. In this article, we will talk about a few clients that you can use from the cli interface. We will do the installations on the Ubuntu operating system.

The ".torrent" file is provided by the application provider you want to download. For example, to download an Ubuntu iso file, go to the web page where the torrent files are published.

download torrent from the cli

Now that we have downloaded the ".torrent" file, let's explain how to use it with different applications.

 

Method-1: Download torrent with Transmission-cli

The Transmission-cli application is located in the Ubuntu repository:

foc@ubuntu22:~$ sudo apt search transmission-cli
Sorting... Done
Full Text Search... Done
libtransmission-client-perl/jammy 0.0806-1 all
  Perl interface to Transmission

transmission-cli/jammy 3.00-2ubuntu2 amd64
  lightweight BitTorrent client (command line programs)

transmission-daemon/jammy 3.00-2ubuntu2 amd64
  lightweight BitTorrent client (daemon)

Use the following command to install:

foc@ubuntu22:~$ sudo apt install transmission-cli -y

Its usage and some parameters are as follows:

Usage: transmission-cli [options] <file|url|magnet>

Options:
 -b  --blocklist                     Enable peer blocklists
 -B  --no-blocklist                  Disable peer blocklists
 -d  --downlimit            <speed>  Set max download speed in kB/s
 -D  --no-downlimit                  Don't limit the download speed
 -f  --finish               <script> Run a script when the torrent finishes
 -g  --config-dir           <path>   Where to find configuration files
 -p  --port                 <port>   Port for incoming peers (Default: 51413)
 -u  --uplimit              <speed>  Set max upload speed in kB/s
 -U  --no-uplimit                    Don't limit the upload speed
 -v  --verify                        Verify the specified torrent
 -w  --download-dir         <path>   Where to save downloaded data

As an example, let's download a file using the -w parameter.  We downloaded the torrent file before:

foc@ubuntu22:~$ ls *.torrent
ubuntu-22.04.1-desktop-amd64.iso.torrent

We have the torrent file and we have the app to download, let's download it:

foc@ubuntu22:~$ transmission-cli ubuntu-22.04.1-desktop-amd64.iso.torrent -w ~/iso/

After this command, the download will be completed depending on your internet speed.

 

Method-2: Download torrent with lftp

Another application you can use to download torrents on Ubuntu is lftp:

foc@ubuntu22:~$ sudo apt search lftp

lftp/jammy,now 4.9.2-1build1 amd64 [installed]
  Sophisticated command-line FTP/HTTP/BitTorrent client programs

It is not installed by default, run the following command to install it:

foc@ubuntu22:~$ sudo apt install lftp -y

After installation, log in by typing lftp in the console. Type torrent and then show torrent file:

foc@ubuntu22:~$ lftp
lftp :~> torrent ubuntu-22.04.1-desktop-amd64.iso.torrent
ubuntu-22.04.1-desktop-amd64.iso: dn:0 up:0 complete:0/14599 (0%)

You can see that the download has started.

To download torrents with hash:

lftp> torrent 3b245504cf5f11bbdbe1201cea6a6bf45aee1bc0

To download a torrent with a magnet URL:

lftp> torrent https://torrent.ubuntu.com/file?info_hash=%3B%24U%04%CF_%11%BB%DB%E1%20%1C%EAjk%F4Z%EE%1B%C0

 

Method-3: Download with Aria2

Another torrent client is Aria2. The following version is available in the Ubuntu repositories:

foc@ubuntu22:~$ sudo apt search aria2
Sorting... Done
Full Text Search... Done
aria2/jammy,now 1.36.0-1 amd64 [installed]
High speed download utility

It is installed with the following command:

foc@ubuntu22:~$ sudo apt install aria2 -y

Let's download the ubuntu-22.04.1-live-server iso using Aria2:

foc@ubuntu22:~$ aria2c https://releases.ubuntu.com/jammy/ubuntu-22.04.1-live-server-amd64.iso.torrent

12/10 08:53:41 [NOTICE] Downloading 1 item(s)

12/10 08:53:42 [NOTICE] Download complete: /home/foc/ubuntu-22.04.1-live-server-amd64.iso.torrent

12/10 08:53:42 [ERROR] Exception caught while loading DHT routing table from /home/foc/.cache/aria2/dht.dat
Exception: [DHTRoutingTableDeserializer.cc:82] errorCode=1 Failed to load DHT routing table from /home/foc/.cache/aria2/dht.dat

12/10 08:53:42 [NOTICE] IPv4 DHT: listening on UDP port 6925

12/10 08:53:42 [NOTICE] IPv4 BitTorrent: listening on TCP port 6975

12/10 08:53:42 [NOTICE] IPv6 BitTorrent: listening on TCP port 6975
[#d293c8 1.0MiB/1.3GiB(0%) CN:1 SD:0 DL:56KiB ETA:7h5m11s]             
12/10 08:54:05 [NOTICE] Shutdown sequence commencing... Press Ctrl-C again for emergency shutdown.


12/10 08:54:05 [NOTICE] Download GID#d293c8c14b2e4cbe not complete: /home/foc/ubuntu-22.04.1-live-server-amd64.iso

Download Results:
gid   |stat|avg speed  |path/URI
======+====+===========+=======================================================
da0c83|OK  |   269KiB/s|/home/foc/ubuntu-22.04.1-live-server-amd64.iso.torrent
d293c8|INPR|    43KiB/s|/home/foc/ubuntu-22.04.1-live-server-amd64.iso

Status Legend:
(OK):download completed.(INPR):download in-progress.

aria2 will resume download if the transfer is restarted.
If there are any errors, then see the log file. See '-l' option in help/man page for details.

To download a torrent with a magnet URL:

aria2 https://torrent.ubuntu.com/file?info_hash=%3B%24U%04%CF_%11%BB%DB%E1%20%1C%EAjk%F4Z%EE%1B%C0

 

Other Alternatives

There are many alternatives, we have listed a few applications that you can reach quickly:

 

rtorrent

foc@ubuntu22:~$ sudo apt search rtorrent

rtorrent/jammy,now 0.9.8-1build1 amd64 [installed]
ncurses BitTorrent client based on LibTorrent from rakshasa

 

ctorrent

foc@ubuntu22:~$ sudo apt install ctorrent -y

foc@ubuntu22:~$ sudo apt search ctorrent
Sorting... Done
Full Text Search... Done
ctorrent/jammy,now 1.3.4.dnh3.3.2-5build1 amd64 [installed]
BitTorrent Client written in C++

 

deluge-console

foc@ubuntu22:~$ sudo apt search deluge-console

deluge-console/jammy,now 2.0.3-3.1 all [installed]
  bittorrent client written in Python/PyGTK (console ui)

 

Summary

We explained the steps to download torrents with CLI on Ubuntu. The choice is yours, you can use the application you want.

You can get help from the manual pages of all mentioned applications. Example:

foc@ubuntu22:~$ man deluge-console

NAME
       deluge-console - A BitTorrent client console interface

SYNOPSIS
       deluge-console [options]

 

References

 

Omer Cakmak

Omer Cakmak

He is highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on OpenStack, KVM, Proxmox, and VMware. You can connect with him on his LinkedIn profile.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

Leave a Comment