Linux > Command line BitTorrent client

Posted on in Categories Linux, RedHat/Fedora Linux, Shell scripting, Suse Linux, Tip of the day, Tips, Ubuntu Linux, UNIX last updated March 14, 2005

BitTorrent is the name of a peer-to-peer (P2P) file distribution protocol, and of a free software implementation of that protocol.

The BitTorrent client is a computer program developed by BitTorrent, Inc. used to download and upload files via the BitTorrent protocol. You can download python based command line BitTorrent client download for Linux/BSD/Mac OS X/UNIX link oses. This is quite useful, if you would like to download file remotely over SSH session. bittorrent.com offers bittorrent client in .deb (Debian Linux) or rpm (RedHat/Fedora Core/CentOS Linux) file formats.

To use the bittorrent in command line one you need to use command bittorrent-console or bittorrent-curses (see below for examples).

Step # 1: Find Python version

Make sure you download file according to your python version. Type following command to find out python version:
$ python -V
Output:

Python 2.4.2

Step # 2: Download bittorrent client

Use wget to download bittorrent client

Download bittorrent client for Debian Linux:

$ wget http://download.bittorrent.com/dl/bittorrent_5.0.3_python2.4.deb

Download bittorrent clientFor Red Hat / Fedora Core / Cent OS Linux

$ wget http://download.bittorrent.com/dl/BitTorrent-5.0.3-1-Python2.4.noarch.rpm

Step # 3: Linux Install BitTorrent client

First login as a root user (use su or sudo command). If you are using Debian Linux, use dpkg command install bittorrent client
# dpkg -i bittorrent_5.0.3_python2.4.deb
If you are using Red Hat / Fedora Core /Cent OS Linux, use rpm command install bittorrent client:
# rpm -ivh BitTorrent-5.0.3-1-Python2.4.noarch.rpm

Step # 4: Start using or downloading files

Use bittorrent client as follows:
$ /usr/bin/bittorrent-curses 'http://www.some.org/DesktopBSD.iso.torrent'
OR
$ bittorrent-curses 'http://www.some.org/DesktopBSD.iso.torrent'
OR
$ /usr/bin/bittorrent-curses '/path/to/file.torrent'
You can try out pure console based client bittorrent-console instead of curses based client:
$ bittorrent-console '/path/to/file.torrent'
$ /usr/bin/bittorrent-console 'http://www.some.org/DesktopBSD.iso.torrent'

Tips about using and Troubleshooting BitTorrent client

(A) If you get [Errno 2] No such file or directory, you need to use wget or lynx command to download .torrent file to local hard drive first. For example
$ bittorrent-curses 'http://www.mininova.org/get/some_file[222].torrent'
First download download .torrent file using any one of the following method:
$ lynx 'http://www.mininova.org/get/some_file[222].torrent'
When prompted save .torrent file to a hard-disk. Another option is use wget to download .torrent file:
$ wget 'http://www.mininova.org/get/some_file[222].torrent'
Now start the downloading as follows:
$ bittorrent-curses 'some_file[222].torrent'

(B) If you get error ‘This seems to be an old Python version which does not support detecting the filesystem encoding. Assuming ‘ascii’, then upgrade your python version to 2.4.xx:

Debian user upgrade python version using apt-get command:
# apt-get update
# apt-get install python2.4

Red Hat Linux user try out:
# up2date python2.4
Fedora Linux user try out:
# yum install python2.4

Remember if you have both versions (python v2.3 and v2.4) installed, you need to run bittorent client as follows:
$ python2.4 /usr/bin/bittorrent-curses '/path/to/file.torrent'
Command line BitTorrent client should work with other UNIX like operating systems such as FreeBSD/OpenBSD/Solaris etc (as long as you have Python it should work).

The current client enables a range of features including multiple parallel downloads. It also intermediates peering between itself, source file servers (read as trackers) and other clients, thereby yielding great distribution efficiencies. The client also enables users to create and share torrent files. See help files for more information.

See also:

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

94 comment

  1. Also use btdownloadheadless.py (or curses) by itself to get the help output. Various command switches are taken. –max_upload_rate $INT –super-seeder $BOOLEAN – etc.

  2. Very nice post, but i screwd it somehow 🙁
    Here’s the error i got:
    Traceback (most recent call last):
    File “/usr/bin/btdownloadheadless.py”, line 24, in ?
    from BitTorrent.download import Feedback, Multitorrent
    ImportError: No module named BitTorrent.download

  3. > ImportError: No module named BitTorrent.download

    I had that error on my box and found this problem/solution:
    – /usr/lib/python a link to /usr/lib/python2.2
    – /usr/lib/python2.3 had been created during rpm install of BitTorrent and contained nothing but a dir /site-packages (belonging to BitTorrent
    – copying that directory to /python2.2 fixed the problem

    have fun

  4. Your post helps a lot.

    I have tried using the command ./btdownloadcurse.py. I found that it is not possible to have it run as a background job ! Why ? Is it possible to run bittorrent jobs, either d/l or u/l in background ?

    Panya

  5. Another question, I got a warning (guess it is not an error) saying that :
    [13:57:00] Python failed to autodetect filesystem encoding. Using ‘ascii’ instead.

    What should I do ?

  6. It should be in /usr/bin/ directory. Try as follows:

    $ cd /usr/bin
    $ ./btdownloadheadless.py path/to/file.torrent

    You can also use following trick to find out path to btdownloadheadless.py
    # dpkg –contents btclientfile.deb | grep btdownloadheadless.py

  7. Hello

    I’m getting following error I’m using /usr/bin/bittorrent-curses under Debian linux:

    Traceback (most recent call last):
    File “/usr/bin/bittorrent-curses”, line 17, in ?
    from BitTorrent.platform import install_translation
    ImportError: cannot import name install_translation

    Any idea?

  8. Thx!!!

    Installed on my dedicated 😀

    download rate: 55.7 KB/s
    upload rate: 16.1 KB/s
    share rating: 0.713 (19.1 MB up / 26.8 MB down)
    seed status: 14 seen now, plus 2 distributed copies (3:99.6%, 4:96.5%, 5:85.9%)
    peer status: 15 seen now

    :DDDD

  9. I can’t seem to get this to work. I keep getting:
    Traceback (most recent call last):
    File “/usr/bin/bittorrent-curses”, line 18, in ?
    from BitTorrent.platform import install_translation
    ImportError: No module named BitTorrent.platform

    If I check the python version with python -V I get Python 2.4.2

    I have tried running the bittorrent command as both python and python2.4 and get the same error in both cases.

    In /usr/local/bin I can see 2 files:
    python & python2.4 both with the same size and timestamp.

    In /usr/lib I have a python2.2 directory and a python2.4 directory.

    The python2.2 directory has a whole bunch of files in it, while the python2.4 directory only has a site-packages directory.

    I have tried uninstalling and reinstalling both python2.4 and bittorrent with no success so far.

    Any suggestions?

  10. Run it as follows:

    python2.4 /usr/bin/bittorrent-curses ‘/path/to/file.torrent’

    OR

    python2.4 /usr/bin/bittorrent-curses ‘http://somewhere.com/file.torrent’

    >The python2.2 directory has a whole bunch of files in it, while the python2.4 directory only has a site-packages directory.

    Hmm i have more than 500+ files in /usr/lib .. try to install python-all. If you are using Debian then it is really easy:
    apt-get install python2.4

    Above command should install all files.

  11. Hi,
    It works, if you have this:

    File “/usr/bin/bittorrent-curses”, line 18, in ?
    from BitTorrent.platform import install_translation
    ImportError: No module named BitTorrent.platform

    Just check if your /usr/bin/python is linked with /usr/bin/python2.4
    if not do:
    1/ rm /usr/bin/python
    2/ ln -s /usr/bin/python2.3 /usr/bin/python

    3/ Enjoy

    JJ

  12. dl speed: 150.1 KB/s ul speed: 19.8 KB/s sharing: 0.167 (27.5 MB up / 164.5 MB down) seeds: 64 seen now, plus 0 distributed copies(1:99.9%, 2:98.6%, 3:91.6%) peers: 16 seen now

    sad thing is that utorrent over cable is faster at over 200 KB/s

  13. How do I stop torrents? I mean I have torrents downloading but what do I do (in SSH) to stop that torrent? I can’t seem to get to a command line either, it just keeps showing the information of speeds, % complete etc…

  14. Hi there, and thank you for a nice page.

    I’m getting:
    File “/usr/bin/bittorrent-curses”, line 18, in ?

    and yet am using python2.4, my python is linked to 2.4 and I’ve tried explicitly running it as 2.4 as well… still no joy.

    Any other explanations?
    Dan.

  15. Hi Dan,

    It seems that some problem exists there for Debian if you are looking for GUI client try out azureus bittorent java client. If you don’t wanna use GUI client then above method should work for you.

    Try out:
    python2.4 /usr/bin/bittorrent-curses ‘path/to/bottorent-file’
    azureus

  16. That is what I have been using :S
    none of the /usr/bin/bittorrent* files run, all generate this error.

    btdownloadgui however works fine, but I sometimes wish to start a transfer over ssh.

    Dan.

  17. Ok. I just try out latest .deb file from official site and you are right it is broken. But I was able to run it via source code. Try out following 4 command it should work on any Linux computer.

    Download source code
    wget http://www.bittorrent.com/dl/BitTorrent-4.4.0.tar.gz

    Untar code
    tar -zxvf BitTorrent-4.4.0.tar.gz

    Goto dirctory:
    cd BitTorrent-4.4.00

    Start GUI Client
    ./bittorrent

    Start Console Client
    ./bittorrent-curses

    Let me know if it works or not.

  18. Thank you 🙂

    I had found btdownloadcurses on my machine, that worked as well.

    Note also that an alternative to nohup is screen. You can run a command with screen like:

    screen btdownloadcurses http://www.site.etc/to.torrent

    press ctrl+a then d to detach from the process

    you can then regain control by issueing

    screen -r
    Dan.

  19. How to close the screen completely?

    [[email protected] html]# screen -r
    There are several suitable screens on:
    11809.pts-0.server (Detached)
    20081.pts-0.server (Attached)
    11582.pts-0.server (Detached)
    Type “screen [-d] -r [pid.]tty.host” to resume one of them.

  20. Hi,
    I’d like to set up my console bittorrent to running only in some configured time. For example from 2 to 8 in the night. I now use cron ok no problem. But how to set up time how long launchmany-curses (I’m using it because I’ve a lot of torrent files) have to work ?
    I know I can use kill but then on trackers connections isn’t well ended and I think there must be better way to achive this goal.

    Greetings,
    krutny

  21. I got these messages, anyone can help me?

    lw13n971:/usr/src# python2.4 /usr/bin/bittorrent-curses ‘/usr/src/test.torrent’
    root : STDERR Traceback (most recent call last):
    root : STDERR File “/usr/bin/bittorrent-curses”, line 31, in ?
    root : STDERR from BitTorrent.MultiTorrent import MultiTorrent, TorrentAlreadyRunning
    root : STDERR File “/usr/lib/python2.4/site-packages/BitTorrent/MultiTorrent.py”, line 25, in ?
    root : STDERR from BitTorrent.Torrent import Feedback, Torrent
    root : STDERR File “/usr/lib/python2.4/site-packages/BitTorrent/Torrent.py”, line 34, in ?
    root : STDERR from BitTorrent.ConnectionManager import ConnectionManager
    root : STDERR File “/usr/lib/python2.4/site-packages/BitTorrent/ConnectionManager.py”, line 22, in ?
    root : STDERR from BitTorrent.RawServer_twisted import Handler
    root : STDERR File “/usr/lib/python2.4/site-packages/BitTorrent/RawServer_twisted.py”, line 45, in ?
    root : STDERR from twisted.python import threadable
    root : STDERR ImportError: No module named twisted.python
    lw13n971:/usr/src#

  22. Thanks, excellent article.
    I have a couple of doubts, though. I haven’t been able to resume downloading a previously stopped torrent.
    I got this message, only once:

    “These errors occurred during execution:
    [10:56:02] Could not load fastresume data: Another program appears to have modified the file, or BitTorrent may have crashed last time it was run. Will perform full hash check.”

    Do you have any tip for resuming? As it is now, every time I stop it I have to start all over again.

    thanks, Emiliano

  23. I’m searcing for a way to remotely control any bittorrent client by ssh, meaning that I can see the download progress, stop it, add another download, etc.

    Is it possible with the official BitTorrent? Do you know any other torrent client that can do this?

  24. 🙁

    can any one help me

    [email protected] [~/Python-2.5]# rpm -ivh BitTorrent-5.0.3-1-Python2.4.noarch.rpm
    error: Failed dependencies:
    /usr/bin/python2.4 is needed by BitTorrent-5.0.3-1.noarch
    python(abi) = 2.4 is needed by BitTorrent-5.0.3-1.noarch
    python-crypto >= 2.0 is needed by BitTorrent-5.0.3-1.noarch
    python-psyco is needed by BitTorrent-5.0.3-1.noarch
    python-twisted >= 2.0 is needed by BitTorrent-5.0.3-1.noarch
    python-zopeinterface is needed by BitTorrent-5.0.3-1.noarch
    wxPython >= 2.6 is needed by BitTorrent-5.0.3-1.noarch

    ??

    [email protected] [~/Python-2.5]# python -V
    Python 2.5

    can any onw tell me ?? how to solve this problem ?

  25. Sorry .,

    But after it’s work .. it gave me this messege

    These errors occurred during execution:
    [19:33:53] Could not load fastresume data: invalid literal for int(): 1167527459.0 Will perform full hash check.
    [19:33:54] Aborting the torrent as it was rejected by the tracker while not connected to any peers. Message from the tracker: unregistered torrent

  26. I looking for software can run in my server ( not my computer ). So I can download file using torrent in my server and then when it completes, I download to my computer.
    Do not blame me if my idea is bad!:D
    Help me please!
    Thanks.

  27. -sh-2.05b$ python2.4 /home/radon86/Download/BitTorrent-4.4.0/bittorrent-curses.py ‘Pirates_of_the_Caribbean.At_Worlds_End.TS.XViD_-_NL_Subs_srt_-^mininova.org^-.torrent’
    ——————————————————————————
    | file: |
    | size: |
    | dest: |
    | progress: |
    | status: |
    | dl speed: |
    | ul speed: |
    | sharing: |
    | seeds: |
    | peers: |
    | |
    | |
    | |
    | |
    | |
    | |
    | |
    | |
    | |
    | |
    | |
    | |
    | |
    | |
    | |
    Traceback (most recent call last):———————————————
    File “/home/radon86/Download/BitTorrent-4.4.0/bittorrent-curses.py”, line 445, in ?
    curses_wrapper(dl.run)
    File “/usr/local/lib/python2.4/curses/wrapper.py”, line 44, in wrapper
    return func(stdscr, *args, **kwds)
    File “/home/radon86/Download/BitTorrent-4.4.0/bittorrent-curses.py”, line 349, in run
    self.d = CursesDisplayer(scrwin, self.errlist, self.doneflag, reread, ulrate)
    File “/home/radon86/Download/BitTorrent-4.4.0/bittorrent-curses.py”, line 117, in __init__
    curses.use_default_colors()
    _curses.error: use_default_colors() returned ERR
    -sh-2.05b$

    ——————–
    help me please

    now i have install python 2.4.4

    when i use rpm command to install bitcomment it’s show

    -sh-2.05b$ rpm -ivh BitTorrent-5.0.3-1-Python2.4.noarch.rpm
    error: Failed dependencies:
    /usr/bin/python2.4 is needed by BitTorrent-5.0.3-1
    python >= 2.3 is needed by BitTorrent-5.0.3-1
    python(abi) = 2.4 is needed by BitTorrent-5.0.3-1
    python-crypto >= 2.0 is needed by BitTorrent-5.0.3-1
    python-psyco is needed by BitTorrent-5.0.3-1
    python-twisted >= 2.0 is needed by BitTorrent-5.0.3-1
    python-zopeinterface is needed by BitTorrent-5.0.3-1
    wxPython >= 2.6 is needed by BitTorrent-5.0.3-1
    -sh-2.05b$

    please slove my problem

  28. I also have Python 2.4.4 and the only failed dependency is python-zopeinterface, which is needed by BitTorrent-5.0.7-1.noarch.
    I have installed python-zope-interface which it seems is not the same thing. I have tried a python-zopeinterface from FC5 but does not work with my FC6.
    Does anyone else have similar problems?

  29. I want to run effectively a torrent daemon which I can take up and down as I please. However using nohup and running bittorrent-curses in the background doesn’t seem to work. As soon I enter another command bittorrent-curses stops working.

    Any advice?

  30. I found that under Fedora Core 6, the only way to get nohup to cooperate with this was to run the command:

    nohup python /usr/bin/bittorrent-console –display_interval 60 path-to-torrentfile &

    the tricks here being:
    1) You need to set the display interval pretty high so that it doesnt flood your nohup.out with messages.
    2) You need to explicitly execute this with python..

    Thanks,
    Rob Goretsky

  31. I’m also getting the python-zopeinterface is needed by BitTorrent-5.0.3-1 error

    I do have a python-zope-interface package installed though. is this the same package?? I’m using Fedora Core 6

  32. For the install issues, just:

    rpm -ivh http://download.bittorrent.com/dl/BitTorrent-5.2.0-1-Python2.4.noarch.rpm –nodeps

    Then run it via:

    cd /usr/bin
    ./btdownloadcurses.py /path/to/torrent

    Then you’ll get a screen like this:

    file: National.Treasure.Book.of.Secrets.TS.DivX-LTT

    size: 741,703,680 (707.3 MB)

    dest: /usr/bin/National.Treasure.Book.of.Secrets.TS.DivX-LTT

    speed: 174.8 KB/s down – 86.6 KB/s
    | totals: 650.5 MB down – 130.5 MB up
    | error(s):

  33. For reference for anyone else in pain of my problem;

    [[email protected] Download]# rpm -ivh BitTorrent-5.0.3-1-Python2.4.noarch.rpm
    error: Failed dependencies:
    /usr/bin/python2.4 is needed by BitTorrent-5.0.3-1.noarch
    python(abi) = 2.4 is needed by BitTorrent-5.0.3-1.noarch
    python-psyco is needed by BitTorrent-5.0.3-1.noarch
    python-twisted >= 2.0 is needed by BitTorrent-5.0.3-1.noarch
    python-zopeinterface is needed by BitTorrent-5.0.3-1.noarch
    wxPython >= 2.6 is needed by BitTorrent-5.0.3-1.noarch

    Try this ling instead;
    [[email protected] Download]# rpm -ivh –nodeps BitTorrent-5.0.3-1-Python2.4.noarch.rpm

    Then use by;
    /usr/bin/bittorrent-curses http://www.yourtorrentfile.com/file.torrent

  34. File “/usr/bin/bittorrent-curses”, line 19, in ?
    from BitTorrent.translation import _
    File “/usr/lib/python2.4/site-packages/BitTorrent/__init__.py”, line 49, in ?
    from BitTorrent.platform import get_temp_subdir, get_dot_dir, is_frozen_exe
    File “/usr/lib/python2.4/site-packages/BitTorrent/platform.py”, line 120, in ?
    from BTL.defer import ThreadedDeferred
    File “/usr/lib/python2.4/site-packages/BTL/defer.py”, line 15, in ?
    from twisted.internet import defer
    ImportError: No module named twisted.internet

    i got this after i finish install the bittorent
    please help

    thanks

  35. Hi,

    I am facing some issues when attempting to use bittorent-curses (or -console, same story):

    # python bittorrent-curses.py
    Traceback (most recent call last):
    File "bittorrent-curses.py", line 19, in
    from BitTorrent.translation import _
    File "/mnt/sda6/install/BitTorrent-5.2.2/BitTorrent/__init__.py", line 49, in
    from BitTorrent.platform import get_temp_subdir, get_dot_dir, is_frozen_exe
    File "/mnt/sda6/install/BitTorrent-5.2.2/BitTorrent/platform.py", line 120, in
    from BTL.defer import ThreadedDeferred
    File "/mnt/sda6/install/BitTorrent-5.2.2/BTL/defer.py", line 54, in
    DeferredQueue = defer.DeferredQueue
    AttributeError: 'module' object has no attribute 'DeferredQueue'

    If I’m going in defer.py and commenting out the offending line (the DeferredQueue variable doesn’t seem to be used anyway), I end up with:

    # python bittorrent-curses.py
    /mnt/sda5/usr/local/lib/python2.5/site-packages/OpenSSL/__init__.py:11: RuntimeWarning: Python C API version mismatch for module rand: This Python has API version 1013, module rand has version 1012.
    import rand, crypto, SSL, tsafe
    /mnt/sda5/usr/local/lib/python2.5/site-packages/OpenSSL/__init__.py:11: RuntimeWarning: Python C API version mismatch for module crypto: This Python has API version 1013, module crypto has version 1012.
    import rand, crypto, SSL, tsafe
    /mnt/sda5/usr/local/lib/python2.5/site-packages/OpenSSL/__init__.py:11: RuntimeWarning: Python C API version mismatch for module SSL: This Python has API version 1013, module SSL has version 1012.
    import rand, crypto, SSL, tsafe
    Traceback (most recent call last):
    File "bittorrent-curses.py", line 34, in
    from BitTorrent.MultiTorrent import MultiTorrent, TorrentAlreadyRunning
    File "/mnt/sda6/install/BitTorrent-5.2.2/BitTorrent/MultiTorrent.py", line 25, in
    from BitTorrent.Torrent import Feedback, Torrent
    File "/mnt/sda6/install/BitTorrent-5.2.2/BitTorrent/Torrent.py", line 32, in
    from BitTorrent.ConnectionManager import ConnectionManager
    File "/mnt/sda6/install/BitTorrent-5.2.2/BitTorrent/ConnectionManager.py", line 21, in
    from BitTorrent.RawServer_twisted import Handler
    File "/mnt/sda6/install/BitTorrent-5.2.2/BitTorrent/RawServer_twisted.py", line 56, in
    from BTL.ConnectionRateLimitReactor import connectionRateLimitReactor
    File "/mnt/sda6/install/BitTorrent-5.2.2/BTL/ConnectionRateLimitReactor.py", line 23, in
    from twisted.internet import error, address, abstract
    ImportError: cannot import name address

    Here I cannot comment out lines. as error is used later in the program.

    What should I do?

    Thanks for advise,
    SxN

  36. I use screen on remote box to keep an instance of btlaunchmanycurses active all the time. I just scp torrent files to specified directory, and then rm them and scp completed downloads back to my PC. It has worked perfect for me but now I have problem. TPB and other sites are starting to use magnet links. So my question is…
    Do you know any CLI p2p client, that handles magnet links?

  37. ” —————————————————————————————————–
    | file: Haunted Manor 2- Queen of Death CE.rar |
    | size: 751,689,629 (716.9 M) |
    | dest: /home/tapas/Haunted Manor 2- Queen of Death CE.rar |
    | progress: _________________________________________________________________________________________ |
    | status: connecting to peers (0.0%) |
    | speed: 0 B/s down – 0 B/s up |
    | totals: 0.0 M down – 0.0 M up |
    | error(s): [23:24:57] Problem connecting to tracker – HTTP Error 503: Service Unavailable ”
    how can i get rid of this problem??

  38. Hello, thank you for this info but I can’t seem to make it work. When I tried bittorrent-curses the message was:

    bittorrent-curses: command not found

    I am sure that it is installed. Can you tell me what’s wrong?

    When I tried to install it again, here’s the message:

    sudo apt-get install python-bittorrent
    Reading package lists… Done
    Building dependency tree
    Reading state information… Done
    python-bittorrent is already the newest version.
    0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

    Please help.

  39. error: Failed dependencies:
    python-psyco is needed by BitTorrent-5.0.3-1.noarch
    python-twisted >= 2.0 is needed by BitTorrent-5.0.3-1.noarch
    python-zopeinterface is needed by BitTorrent-5.0.3-1.noarch
    wxPython >= 2.6 is needed by BitTorrent-5.0.3-1.noarch

  40. Can anybody help me resolve this issue with Bittorrent.
    ERROR:
    [16:10:37] Problem connecting to tracker –

    [[email protected] Desktop]# netstat -an |grep -i 6881
    tcp 0 0 0.0.0.0:6881 0.0.0.0:* LISTEN
    udp 0 0 0.0.0.0:6881 0.0.0.0:*
    [[email protected] Desktop]# netstat -an |grep -i 6889
    [[email protected] Desktop]# python -V
    Python 2.4.3

Leave a Comment