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.
![]()
Img.1 rTorrent — right after start
![]()
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!
20 Comments
- 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>

















“A|S|D — decrease global download speed about 1|5|50 KB/s”
you mean Z|X|C?
Yes, of course, corrected.
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
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”)
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.
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
# 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
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
This should be quite easy to do with a bash script using some command-line downloader like wget or curl.
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
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
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
Could be usefull: http://bartik.wikidot.com/synology:broadcatch
karlo
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/rtorrentHabia 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.
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.
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
thank you!
how is it with trackers where is a registration needed? is there a posibility to enter a login? thx
HoKe
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
and finally describes how to enable encription in rTorrent
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…