rTorrent — console P2P!

[ Wednesday, 25 July 2007, Treadstone ]


In this article I’d like to describe a text-mode Bittorrent client – rTorrent. It will be helpful to people that share a computer with other household members because it allows them to download files regardless of the logged in user. What’s more, because it is a text-mode client (runs under ncurses) you can watch how it works through any ssh client, web browser (ajaxterm) or even cell phone (MidpSSH). Wikipedia and the official website says that the very optimized code makes rTorrent much faster than the official client. So, do you want more? Bring it on!

What do you need?

First of all you will need a copy of rTorrent and libtorrent libs. You can download these two from the official website but first check your distribution’s repository. We will need also a program screen, which should be found in most repositories.

If you have already installed these packages, you can run rTorrent now. Just write “rtorrent” in a terminal. What appears is described below. You will feel a little bit confused for sure, so I’ll try to explain it all :)

Window description

These two screenshots show the main window of rTorrent. The first one shows you what rTorrent looks like when run for the first time. On the second screen there is a window with two downloads and the configuration file made.

rTorrent - right after start
Img.1 rTorrent — right after start

rTorrent - basic functions description
Img.2 rTorrent — basic functions description

Configuration file

The first question is – “how do we add a new torrents?” The answer is right here: torrents add themselves automatically. “How is it possible?” You will see in a moment :)

The magic is inside the configuration file of rTorrent which is in your home directory named .rtorrent.rc. You should create it now. Example one, which I use is below.

# The settings of torrents will be saved in this directory;
# and a file, which will prevent rTorrent running more than once;
session = /home/lukasz/dane/download/torrenty
# where the downloaded files will be saved;
directory = /home/lukasz/dane/download/torrenty
# Default upload speed (0 means No Limit);
upload_rate = 40 
# Default download speed (0 means No Limit);
download_rate = 0
# if rTorrent should use UDP;
use_udp_trackers = yes 
# Max. number of upload slots per torrent;
max_uploads = 20 
# Port range from where rTorrent will try to connect;
port_range = 6892-6892
# Min. and max. connections to one torrent;
min_peers=10
max_peers=400 
# Stops uploading when ratio is 2.0 and file size greater than 100MB
# or ratio is over 5.0;
schedule = ratio,60,60,stop_on_ratio=200,200M,500
# Stops downloading when there is less than 20MB diskspace;
schedule = low_diskspace,5,60,close_low_diskspace=20M
# Torrents will be automatically added to the download \\
list from this directory ;
schedule = \\
watch_directory,5,5,load_start=/home/lukasz/dane/download/torrenty/*.torrent 
# After deleting torrents from that list .torrent files will be deleted too;
schedule = untied_directory,5,5,stop_untied=

If you have already prepared the configuration file you can check if rTorrent downloads the files automatically. To do this you have to download a torrent file to your download directory (in my case it was “/home/lukasz/dane/download/torrenty”). If rTorrent adds files from the directory it will mean that everything is OK. Otherwise you have to check the configuration file very carefully. Check if it is in the correct directory, has the right name and doesn’t contain any typos.
Of course torrents can also be added manually with keyboard shortcuts.

rTorrent, screen and init scripts

In the next step you will add rTorrent to your init scripts. To do this you will prepare a little script which you will add to /etc/init.d. You can read how to do this in article about /etc/init.d written by Bober. In my case it looks like this:

#!/bin/sh
su lukasz -c 'screen -mD sh /usr/bin/rtorrent';

Instead of “lukasz”, you have to write your own username what will made rTorrent not to run with a root privileges.

If you want to start this script on system startup you have to (with root privileges) make it executable (chmod +x), copy it to /etc/init.d/ and then run update-rc.d file defaults 20 where file is the name of the script.

After rebooting, rTorrent should run automatically. To see it you have to enter screen -r in any terminal. The full description of not only basic functions of the screen you can find in Screen: Tips & Tricks.

Basic keyboard shortcuts

  • ^q — closes rTorrent, done twice makes the program shutdown.
  • Up, down arrows — highlight the downloads.
  • Left arrow — returns to the previous screen.
  • Right arrow — goes to the next screen.
  • a|s|d — increase global upload speed about 1|5|50 KB/s
  • A|S|D — increase global download speed about 1|5|50 KB/s
  • z|x|c — decrease global upload speed about 1|5|50 KB/s
  • Z|X|C — decrease global download speed about 1|5|50 KB/s
  • ^S — starts download
  • ^D — pauses and resumes the active download
  • +|- — changes the download priority of selected torrent.
  • Backspace — adds the specified .torrent. After pressing this button write full path or URL of .torrent file. You can use Tab and other tricks from bash.

I hope the information I presented here will be useful. Obviously it is not 100% of rTorrent’s features but certainly this is enough to easily use the program. For more information take a look at the manuals. You can also ask any questions in the comments or personaly by writing to lukiasz(at)gmail.com

Subscribe to RSS feed for this article!

23 Comments

fold this thread Taras Halturin  Wednesday, 25 July 2007 o godz. 10:02 am #  Add karma Subtract karma  +0

“A|S|D — decrease global download speed about 1|5|50 KB/s”
you mean Z|X|C?

(Comments wont nest below this level)
fold this thread michuk  Wednesday, 25 July 2007 o godz. 10:28 am #  Add karma Subtract karma  +0

Yes, of course, corrected.

 
fold this thread Calomel  Sunday, 28 October 2007 o godz. 1:18 am #  Add karma Subtract karma  +0

This is correct: Z|X|C == decrease global download speed about 1|5|50 KB/s

If you need more help on rTorrent here is a study of rTorrent and modifications you can make.

rTorrent study and mods

 
 
fold this thread Matt  Thursday, 2 August 2007 o godz. 8:47 am #  Add karma Subtract karma  +0

Wouldn’t it be easier simply to use cron to start it back up?

Add “@reboot screen -D -m /usr/bin/rtorrent” to one’s crontab (by using “crontab -e”)

(Comments wont nest below this level)
 
fold this thread pilsna  Wednesday, 8 August 2007 o godz. 11:49 am #  Add karma Subtract karma  +0

I’ve always run Azureus before, but this article made it really easy to get started with rtorrent. I’m stuck with it now. Thanks.

(Comments wont nest below this level)
 
fold this thread tannedin  Tuesday, 14 August 2007 o godz. 7:19 am #  Add karma Subtract karma  --1

I’m getting a rtorrent: Error in option file: ~/.rtorrent.rc:26: Invalid arguments to command. error with the following config


# The settings of torrents will be saved in this directory;
# and a file, which will prevent rTorrent running more than once;
session = /media/sdc1/dumpish/1_dump/0_file
# where the downloaded files will be saved;
directory = /media/sdc1/dumpish/1_dump/1_part
# Default upload speed (0 means No Limit);
upload_rate = 30
# Default download speed (0 means No Limit);
download_rate = 100
# if rTorrent should use UDP;
use_udp_trackers = yes
# Max. number of upload slots per torrent;
max_uploads = 20
# Port range from where rTorrent will try to connect;
port_range = 6892-6892
# Min. and max. connections to one torrent;
min_peers=10
max_peers=400
# Stops uploading when ratio is 2.0 and file size greater than 100MB
# or ratio is over 5.0;
schedule = ratio,60,60,stop_on_ratio=200,200M,500
# Stops downloading when there is less than 20MB diskspace;
schedule = low_diskspace,5,60,close_low_diskspace=20M
# Torrents will be automatically added to the download \
list from this directory ;
schedule = \
watch_directory,5,5,load_start=/home/lukasz/dane/download/torrenty/*.torrent
# After deleting torrents from that list .torrent files will be deleted too;
schedule = untied_directory,5,5,stop_untied=

any ideas?

also, is there a way to set “unlimited” the ‘file size greater than 100MB in line 21?

thanx
-Tannedin

(Comments wont nest below this level)
 
fold this thread somename  Wednesday, 15 August 2007 o godz. 5:18 am #  Add karma Subtract karma  +0

# Torrents will be automatically added to the download list from this #directory ;

schedule = watch_directory,5,5,load_start=/home/lukasz/dane/download/torrenty/*.torrent

should be one line without the \

http://libtorrent.rakshasa.no/browser/trunk/rtorrent/doc/rtorrent.rc?rev=latest

i think if you just comment (#) the line it will be unlimited

(Comments wont nest below this level)
 
fold this thread Henrik  Thursday, 16 August 2007 o godz. 5:01 pm #  Add karma Subtract karma  +0

Hi,
is there any way to make rtorrent pick up torrents automatically from a RSS feed? Or do you know of a program that can download the .torrent file to the watch directory?

thanks

(Comments wont nest below this level)
fold this thread michuk  Thursday, 16 August 2007 o godz. 7:50 pm #  Add karma Subtract karma  +0

This should be quite easy to do with a bash script using some command-line downloader like wget or curl.

fold this thread Henrik  Friday, 17 August 2007 o godz. 9:56 am #  Add karma Subtract karma  +0

quite easy is relative I guess :-)
I’m a very recent convert from Windows, and haven’t quite gotten to grips with bash scripts yet.

I’m very eager to learn, and I’m determined to stay on linux this time. Are there any good tips you can give me?

thanks

fold this thread karlo  Monday, 17 September 2007 o godz. 12:14 am #  Add karma Subtract karma  +0

I’m configuring a WD MyBook World Edition (500GB) with rTorrent and I’m very interested to add the rss feature to rTorrent!

Any help will be very appreciate!

karlo

 
fold this thread karlo  Monday, 17 September 2007 o godz. 12:38 am #  Add karma Subtract karma  +0

Could be an idea: from http://bartik.wikidot.com/synology:broadcatch

#!/bin/sh
# get the anime titles
wget -q http://www.anime-kraze.org/ -O /tmp/anikraze.html
wget -q http://xdcc.discoveryhosting.nl/tracker/ -O /tmp/kaizoku.html
wget -q http://www.mininova.org/rss/death+note+animanda -O /tmp/animanda.html
wget -q http://www.mininova.org/rss/battlestar+galactica+ws+orenji+eztv -O /tmp/galactica.html
# get the list of new torrents
grep “http:\/\/www.anime-kraze.org\/torrent\/\[Ani-Kraze\]_Angel_Heart_-_” /tmp/anikraze.html|sed -e ‘s/^.*href=”//’ -e ‘s/”>.*$//’ > /tmp/anime.new
sed -e ‘s/td>/td>!/g’ /tmp/kaizoku.html | tr “!” “\n” | grep “/tracker/torrents” | sed -e ‘s/^.*href=”//’ -e ‘s/.torrent”>.*$/.torrent/’ | grep -v “\[BATCH\]” >> /tmp/anime.new
sed -e ‘s/>!” | sed -e ‘s/^//’ -e ‘s/$//’ -e ‘s/\/tor\//\/get\//’ >> /tmp/anime.new
sed -e ‘s/>!” | sed -e ‘s/^//’ -e ‘s/$//’ -e ‘s/\/tor\//\/get\//’ >> /tmp/anime.new
# find out what to download
diff /tmp/anime.old /tmp/anime.new | grep “^>” | sed -e ‘s/^> //’ > /tmp/anime.download
# replace the old list with the new list
rm -f /tmp/anime.old
mv /tmp/anime.new /tmp/anime.old
# send file to mldonkey
date >> /tmp/torrent.log
if [ `wc -l anime.download | awk '{print $1}'` -gt 0 ]; then
for torrent in `cat /tmp/anime.download`; do
wget -q -P /tmp “$torrent”
echo $torrent >> /tmp/torrent.log
filename=`basename $torrent`
#filename=`echo “$torrent” | awk -F’/’ ‘{print $NF}’`
mv /tmp/$filename /volume1/public/debian/chroottarget/root/.mldonkey/torrents/incoming
done
fi
# remove temporary files
rm -f /tmp/anime.download
rm -f /tmp/anikraze.html
rm -f /tmp/kaizoku.html
rm -f /tmp/animanda.html
rm -f /tmp/galactica.html

 
fold this thread karlo  Monday, 17 September 2007 o godz. 12:39 am #  Add karma Subtract karma  +0
 
 
 
 
fold this thread Dirk.R.Gently  Saturday, 18 August 2007 o godz. 9:47 pm #  Add karma Subtract karma  +0

I like the tutorial! A little FYI to use rtorrent in a init-script it took out the “sh” from your command line to get it operate. In fact, I’m not ever sure what it does.

screen -D -m /usr/bin/rtorrent

(Comments wont nest below this level)
 
fold this thread GGC  Saturday, 25 August 2007 o godz. 5:57 pm #  Add karma Subtract karma  --1

Habia probado los front end para los programas Torrent, pero rtorrent me du mucha mas flexibilidad y sencillez :-) . En Gentoo tenemos el paquete a la mano:

% emerge rtorrent -pv

These are the packages that would be merged, in order:

Calculating dependencies… done!
[ebuild R ] net-p2p/rtorrent-0.7.2 USE=”-debug” 0 kB

% emerge rtorrent

y listo para usarlo. La configuración del ejemplo, bastante clara por cierto, deja ver la simplicidad del programa.

(Comments wont nest below this level)
 
fold this thread gejr  Monday, 1 October 2007 o godz. 1:00 pm #  Add karma Subtract karma  +0

You have a tiny error there. ^D doesn’t pause and _resume_. First it stops the download, another ^D and it deletes the torrent file, and removes it from the list. To resume a paused torrent you must use ^S. So, ^D to pause and ^S to resume.

(Comments wont nest below this level)
 
fold this thread Benji  Tuesday, 20 November 2007 o godz. 2:17 pm #  Add karma Subtract karma  +0

nice tute, I’m using an old 200MHz pc with Debian without DE: I connect to it through ssh and rtorrent is perfect for my needs :-D
thank you!

(Comments wont nest below this level)
 
fold this thread HoKe  Wednesday, 19 December 2007 o godz. 12:18 am #  Add karma Subtract karma  +0

how is it with trackers where is a registration needed? is there a posibility to enter a login? thx
HoKe

(Comments wont nest below this level)
 
fold this thread xbisont  Thursday, 28 February 2008 o godz. 5:45 am #  Add karma Subtract karma  +0

this is great, i’m trying to do just what Benji described, and the bash script to automagically add torrents from rss, that’s more than i was looking for, but i even found a little more in other site (http://avi.alkalay.net/2007/11/encrypt-bittorrent.html) it says

Some evil ISPs implement traffic shaping to specifically limit BitTorrent bandwidth. This brings slower downloads to you and your peer.
….
Please configure your client to encrypt connections. You will have faster downloads

and finally describes how to enable encription in rTorrent

(Comments wont nest below this level)
 
fold this thread Sebastian  Sunday, 1 June 2008 o godz. 1:58 pm #  Add karma Subtract karma  +0

This all looks fine – but how the hell am I supposed to use ^S and ^Q over ssh in my shell? This always only works out to stop and resume scrolling.

Any easy fix to this? I’m using PuTTY from XP to Debian Etch with bash 3.1.17 on a NSLU2…

(Comments wont nest below this level)
 
fold this thread Talma  Friday, 5 June 2009 o godz. 11:55 am #  Add karma Subtract karma  +0

rtorrent is cool :D I hope it will support upnp in the future.

A little “trick”:
You can copy .torrent files with scp in your “watch_directory”, and it automatically starts downloading.

(Comments wont nest below this level)
 
fold this thread work from home ideas  Saturday, 24 May 2014 o godz. 11:55 pm #  Add karma Subtract karma  +0

Getting started can be tough, but if you stick with it, post
to forums, create a word-press blog or two, you
can actually get webmasters and others to purchase your services.
Firstly although you could gain qualifications or learn any business
you want, it is always best to stick with what you know or do something you already understand, follow something you have a strong interest in or are already good at.
There are some decent companies out there offering a wide range of
different programs, products and methods.

(Comments wont nest below this level)
 
fold this thread boom beach hack without survey  Sunday, 27 July 2014 o godz. 4:53 am #  Add karma Subtract karma  +0

I don’t even know how I finished up right here, but I believed this
put up was once good. I do not know who you might be but certainly
you’re going to a well-known blogger in case you are
not already. Cheers!

(Comments wont nest below this level)
 
Name (required)
E-mail (required - never shown publicly)
URI

Adjust field size: shrink | enlarge)


You can use simple HTML in your comments. Some examples are as follows:
  • A hyperlink: <a href="polishlinux.org">GNU/Linux for everyone!</a>,
  • Strong text: <strong>Strong text</strong>,
  • Italic text: <em>italic text</em>,
  • Strike: <strike>strike</strike>,
  • Code: <code>printf("hello world");</code>,
  • Block quote: <blockquote>Block quote</blockquote>

About the Author

Łukasz Olender

New AdTaily ads!

Are you a film buff?

film buffs community, movie recommendations and reviews

RSS: Comments

You can follow the comments to this article through a special channel RSS 2.0 .

Related articles: CLI

 more »

Related articles: P2P

 more »

PolishLinux Top Content


Become our fan on Facebook!

PolishLinux.org on Facebook

Follow PolishLinux on Twitter!

Follow polishlinux on Twitter

Google Ads