From ArchWiki
Revision as of 17:20, 2 August 2009 by GD (talk | contribs) (→‎Controls: fixed outgoing link)
Jump to navigation Jump to search

Template:I18n links start Template:I18n entry Template:I18n links end


rTorrent is a very simple, elegant and ultra-light bittorent client. It is written in C++ and uses ncurses, so it is completely text based and runs entirely in a console. rTorrent is ideal for low-end systems and with the addition of GNU Screen and openssh it is convenient as a remote bittorrent client.


pacman -S rtorrent


Before running rTorrent, the first step is to copy the default configuration file which is available at the rTorrent project page and save the file as .rtorrent.rc into your home directory.

Once the file has been saved, open it with your preferred text editor and make any necessary changes. Simply uncomment the options you wish to enable/utilize. For more detailed information on the options available, visit rTorrent Common Tasks

Recommended Configuration

These values in the following are subjective and dependent upon your own system and Internet connection speed. To find the optimal settings for you to use, visit the following website and follow the instructions: Optimize Your BitTorrent Download Speed

# Maximum and minimum number of peers to connect to per torrent.
#min_peers = 40
max_peers = 52

# Same as above but for seeding completed torrents (-1 = same as downloading)
#min_peers_seed = 10
max_peers_seed = 52

# Maximum number of simultanious uploads per torrent.
max_uploads = 8

# Global upload and download rate in KiB. "0" for unlimited.
download_rate = 200
upload_rate = 28

This option below will determine where your torrents data will be saved. Change the default save directory to whatever you wish to use. Be sure to enter the absolute path; there is an odd bug with rTorrent sometimes does not respect relative paths (i.e. ~/torrents):

# Default directory to save the downloaded torrents.
directory = /home/[user]/torrents/

This option will allow rTorrent to save the progess of your torrents. Be sure to create a directory called .session (simply run as normal user:mkdir ~/.session):

# Default session directory. Make sure you don't run multiple instance
# of rtorrent using the same session directory. Perhaps using a
# relative path?
session = /home/[user]/.session/

The following option will have rTorrent "watch" a particular directory for new .torrent files. Using your browser, when you find a .torrent file you would like to download, just save the file into this directory and rTorrent will automatically start the torrent. Be sure to create the directory that will be watched (simply run as normal user:mkdir ~/watch):

# Watch a directory for new torrents, and stop those that have been
# deleted.
#schedule = watch_directory,5,5,load_start=./watch/*.torrent
#schedule = untied_directory,5,5,stop_untied=
schedule = watch_directory,5,5,load_start=/home/[user]/watch/*.torrent
schedule = untied_directory,5,5,stop_untied=
schedule = tied_directory,5,5,start_tied=

This option below will stop rTorrent from downloading any further when disk space is low. This is particuarly useful with a Seedbox where disk space is quite limited. Change the value as you like:

# Close torrents when diskspace is low.
schedule = low_diskspace,5,60,close_low_diskspace=100M

This option will set what port to use for listening. It is recommended to use a port that is higher than 49152. rTorrent allows the use of a single port rather than a range; a single port rather than an actual range is recommended.

# Port range to use for listening.
port_range = 49164-49164

The following option allow for a hash check whenever a torrent is complete or whenever rTorrent is restarted. This will make sure there are no errors with your acquired/seeding files.

# Check hash for finished torrents. Might be usefull until the bug is
# fixed that causes lack of diskspace not to be properly reported.
check_hash = yes

The following option allows for the enabling of encryption. This is very important to enable, if not for yourself, but for others in the torrent swarm; people might need to obscure their bandwidth usage from their ISP. Does not hurt you to enable even if you do not need such protection. More information: Bittorrent Protocol Encryption

# Encryption options, set to none (default) or any combination of the following:
# allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext
# The example value allows incoming encrypted connections, starts unencrypted
# outgoing connections but retries with encryption if they fail, preferring
# plaintext to RC4 encryption after the encrypted handshake
# encryption = allow_incoming,enable_retry,prefer_plaintext
encryption = allow_incoming,try_outgoing,enable_retry

The following is for DHT support. If you use public trackers, you'll want to enable DHT to acquire more peers. If you use only private trackers, do not enable DHT as this will reduce your speeds and can create a privacy risk. Some private trackers will even warn you if you use DHT.

# Enable DHT support for trackerless torrents or when all trackers are down.
# May be set to "disable" (completely disable DHT), "off" (do not start DHT),
# "auto" (start and stop DHT as needed), or "on" (start DHT immediately).
# The default is "off". For DHT to work, a session directory must be defined.
# dht = auto

# UDP port to use for DHT. 
# dht_port = 6881

# Enable peer exchange (for torrents not marked private)
# peer_exchange = yes

Be sure to forward the proper port(s) with your router if you use one. A decent guide per router make/model can be found here.


rTorrent relies exclusively on keyboard shortcuts for user input. A complete guide is available on the main site: rTorrent User Guide

Here are the basics for quick reference:

  • Control-q : closes rTorrent, done twice makes the program shutdown without waiting to send stopping information to the trackers.
  • Left arrow : returns to the previous screen.
  • Right arrow : goes to the next screen.
  • a|s|d : increase global upload throttle about 1|5|50 KB/s
  • A|S|D : increase global download throttle about 1|5|50 KB/s
  • z|x|c : decrease global upload throttle about 1|5|50 KB/s
  • Z|X|C : decrease global download throttle about 1|5|50 KB/s
  • Control-S : starts download
  • Control-D : stops an active download, removes a stopped download.
  • + or - : 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.

Use rTorrent with Screen

Screen is a program that will allow CLI applications to be run in the background and without X running.

To install:

pacman -S screen

and then copy screenrc to your home directory as normal user:

cp /etc/screenrc ~/.screenrc

To have rTorrent always start with screen, add the following to your .screenrc file:

screen -t rtorrent rtorrent 

To start screen + rTorrent, simply run screen from a terminal. Control-a followed by d will detach screen, and running screen -r will open screen again.

On a remote machine

Most setups of rTorrent on a remote machine involve using Screen. Supposing you have a detached Screen session with rtorrent on the remote machine (and the option to SSH into it), you can gain access to it using:

/usr/bin/ssh -t -p <ssh port on remote machine> <user>@<remote machine> screen -RD

If you want immediate access on startup, you will need to upload a key from your machine to remote host (so you will not be prompted for a password) and setup a terminal to run the command above. An inittab example using rungetty on virtual console 4:

sam:45:respawn:/sbin/rungetty tty4 -u <local user> -- /usr/bin/ssh -t -p <ssh port on remote machine> <remote user>@<remote machine> screen -RD

rtorrent Daemon with screen

I use this on my home server to run rtorrent w/ screen as a daemon. With the username rtorrent Just create an rtorrent file in your /etc/rc.d/ and add the following code.


. /etc/rc.conf
. /etc/rc.d/functions

case "$1" in
    stat_busy "Starting rtorrent"
    su rtorrent -c 'screen -d -m rtorrent' &> /dev/null
    if [ $? -gt 0 ]; then
      add_daemon rtorrent
    stat_busy "Stopping rtorrent"
    killall -w -s 2 /usr/bin/rtorrent &> /dev/null
    if [ $? -gt 0 ]; then
      rm_daemon rtorrent
    $0 stop
    sleep 1
    $0 start
    echo "usage: $0 {start|stop|restart}"
exit 0

On a remote computer I use the following script to connect to the server's daemon process:

ssh -t rtorrent@ 'screen -r'

Additional Tips

  • To use rTorrent with a tracker that uses https, do the following as root:
cd /etc/ssl/certs
wget --no-check-certificate https://www.geotrust.com/resources/root_certificates/certificates/Equifax_Secure_Global_eBusiness_CA-1.cer
mv Equifax_Secure_Global_eBusiness_CA-1.cer Equifax_Secure_Global_eBusiness_CA-1.pem

And from now on run rTorrent with:

rtorrent -o http_capath=/etc/ssl/certs

Be sure to change .screenrc to reflect this change if you use screen:

screen -t rtorrent rtorrent -o http_capath=/etc/ssl/certs

Send Text Message Upon Torrent Completion Using GMail

Cell phone providers allow you to "email" your phone:

Verizon: 10digitphonenumber@vtext.com
Former AT&T customers: 10digitphonenumber@mmode.com
Sprint: 10digitphonenumber@messaging.sprintpcs.com
T-Mobile: 10digitphonenumber@tmomail.net
Nextel: 10digitphonenumber@messaging.nextel.com
Cingular: 10digitphonenumber@cingularme.com
Virgin Mobile: 10digitphonenumber@vmobl.com
Alltel: 10digitphonenumber@alltelmessage.com OR
CellularOne: 10digitphonenumber@mobile.celloneusa.com
Omnipoint: 10digitphonenumber@omnipointpcs.com
Qwest: 10digitphonenumber@qwestmp.com

If you have Verizon, your cell phone's "email" is 5551234567@vtext.com

  • Install Heirloom's mailx program:
pacman -Sy mailx-heirloom
  • Clear the /etc/nail.rc file and enter:
set smtp=smtp.gmail.com:587
set smtp-use-starttls
set ssl-verify=ignore
set ssl-auth=login
set smtp-auth-user=USERNAME@gmail.com
set smtp-auth-password=PASSWORD

Now to send the text, we must pipe a message to the mailx program.

  • Make a bash script (/path/to/mail.sh):
echo "Torrent Done" | mailx 5551234567@vtext.com
  • And finally, add the important ~/.rtorrent.rc line:
on_finished = move_complete,"execute=/path/to/mail.sh"

Note: The "move complete" won't affect anything. I couldn't get it to work without it.

See Also

Screen Tips

A Detailed Intro to Bittorrent including definition of terms terms