This post was saved / ported from a previous site migration. You may encounter missing images, dead links, and strange formatting. Sorry about that!

BitTorrent, the Linux way

tutorial bittorrent linux dropbox Technology

I use BitTorrent a lot. Most Linux distributions have torrents available, and I have gotten a lot of Creative Commons-licensed music, such as the work of Jonathan Coulton, via BitTorrent. It is a great way to deliver content.

However, I have a problem with (most of) the available BitTorrent clients. Given what BitTorrent does, which is allow you to download and subsequently seed content, it should really run like a service - quietly running in the background handling your torrents. However, most of the clients for Linux work like Windows applications. They sit in your system tray, giving you “helpful” popup notifications. More importantly, they die if you logout. Luckily, I have found a solution.

Enter transmission-daemon


Transmission is one of the bittorrent clients for Linux that works like I described above - it’s a desktop application. However, it comes with a variant, transmisison-daemon, that can run in the background, as a dedicated ’transmission’ user. This is much nicer.

Setting it up in fedora is pretty easy. Install the transmission-daemon package. Edit /etc/sysconfig/transmission-daemon to suit your needs. You can change TRANSMISSION_HOME to whatever directory you’d like your completed torrent files to live in (you do not need to modify the actual home directory of the transmission user, but do make sure TRANSMISSION_HOME is owned by that user).

Now, start transmission-daemon, then stop it again:
service transmission-daemon start
service transmission-daemon stop

That step created the transmission configuration files, which you can now find in $TRANSMISSION_HOME/.config/transmission-daemon/. The file you probably want to edit is settings.json. Edit this file to suit your needs, then start transmission again. To tell transmission to automatically start at boot, run:
chkconfig transmission-daemon on

transmission-remote - for all your transmission-related needs


So, now you have a daemonized BitTorrent client, running unobtrusively in the background. But how do you use it?

The answer is transmission-remote. This tool is an administrative front-end for transmission-daemon that lets you add, remove, start, stop, and view your torrents, and a lot more besides. To add a torrent, you can use ’transmission-remote -a’ on either a local .torrent file or a URL, like so:
transmission-remote -a /path/to/file.torrent
transmission-remote -a http://example.com/file.torrent

Once the torrent is added, it will automatically start. You can get information on all your torrents with ’transmission-remote -l’. Note that each torrent has a numeric ID assigned to it; you use that ID with the ‘-t’ option to tell transmission-remote to perform actions on the torrent. For example, to stop the torrent with ID 42, you could run:
transmission-remote -t 42 -S

transmission-remote can do a lot more; check its man page for details. In particular, the -s, -i, and –remove-and-delete are useful flags to know.

Making things easier - the watch directory


The problem with the approach I have described is that the command line, while great for interacting with your local torrents, is not the place most people go to look for torrents in the first place. More often, you find a .torrent file on the web, and having to open a terminal and run a command is an annoying extra step.

To make things easier, you can set up a watch directory; any .torrent files placed in that directory will automatically be added to transmission-daemon. To set up a watch directory, edit settings.json and add the following:
watch-dir-enabled: “true”,
watch-dir: “/path/to/watch/dir”,

(I have found it is best to always stop transmission-daemon before making changes to settings.json. It often overwrites settings at shutdown)

One caveat about the watch directory: when transmission-daemon is started, every .torrent file in there will be added. While this has no effect on torrents you are still downloading or seeding, torrents you have already removed will be re-added to transmission-daemon. For this reason, it is a good idea to routinely delete the files in your watch directory. You can use tmpwatch and/or cron to periodically delete the files.

Torrents from anywhere - using Dropbox with transmission-daemon


Dropbox is a fantastic tool for always having access to important files. Any files you put in your dropbox directory get automatically synced to every machine you use dropbox on. There are also Android, iOS, and web interfaces, so you can really get to your files from anywhere.

What does this have to do with transmission? Well, you can put your watch directory inside your dropbox directory. Any .torrent file you add to that directory - from any computer or phone - will automatically be started on the computer running transmission-daemons. This means you can start your torrents whenever you come across them, no matter where in the world you happen to be.

And if you have multiple people in your household who might all like to use one machine for BitTorrent, you can simply share your dropbox watch directory with all of them.

The way computers should behave - the world according to Anna


User interface design is a complicated thing, and a lot of research has gone into it. What a lot of UI discussions miss, though, is that everyone has different needs and preferences. The setup I have described here works the way I personally like best. It is transparent; that is, it gets out of your way and just does what it is supposed to do, with no fuss. It is powerful and flexible. For a Linux power user who prefers to use the command line where she can, it is hard to imagine a better BitTorrent solution.