root@myserver:/qbittorrent/install#

Step 9: Install and Configure qBittorrent

qBittorrent is a powerful and lightweight torrent client. We'll install the server (headless) version called qbittorrent-nox, which works without a graphical desktop.

1. Install qBittorrent-NOX:

user@homeserver:~$ sudo apt install qbittorrent-nox -y

This command installs the server version of qBittorrent and automatically accepts the installation without asking for confirmation.

2. Start qBittorrent manually:

user@homeserver:~$ qbittorrent-nox

You’ll see a message like this in your terminal:

******** Information ********
To control qBittorrent, access the Web UI at: http://localhost:8080
The Web UI administrator username is: admin
The Web UI administrator password was not set. A temporary password is provided for this session: YOUR PASSWORD HERE

Open a browser on another device and go to http://YOUR_LOCAL_IP_ADDRESS:8080. Login with username admin and the temporary password. Then change the password in Preferences → Web UI.

After setting the password, return to the terminal and press Ctrl + C to stop the program. We’ll now set it up to run automatically in the background.

3. Create a systemd service:

user@homeserver:~$ sudo nano /etc/systemd/system/qbittorrent.service

This creates a service file that will tell the system how to run qBittorrent in the background on boot.

Insert this content:

[Unit]
Description=qBittorrent Command Line Client (No GUI)
After=network.target

[Service]
Type=simple
User=user
ExecStart=/usr/bin/qbittorrent-nox
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

Change User=user to match your actual Linux username.

Explanation:

Save and exit: Ctrl + O → Enter → Ctrl + X

4. Reload systemd and enable the service:

user@homeserver:~$ sudo systemctl daemon-reload

This reloads all service definitions so your new file is recognized.

user@homeserver:~$ sudo systemctl enable qbittorrent.service

Enable the service to start automatically when the system boots.

user@homeserver:~$ sudo systemctl start qbittorrent.service

Start the qBittorrent service right now.

user@homeserver:~$ sudo systemctl status qbittorrent.service

Check if it’s running correctly. You should see active (running) in green text.

5. Move downloaded files to MiniDLNA folder:

user@homeserver:~$ sudo mv /home/user/Downloads/* /mnt/usbdrive/media

This moves all downloaded files into the folder where MiniDLNA can stream them. Replace user with your actual username.

6. Refresh MiniDLNA:

user@homeserver:~$ sudo systemctl restart minidlna

This tells MiniDLNA to rescan the folder and update the media library.

7. Automate this process with a script:

Create a script to do everything automatically:

user@homeserver:~$ sudo nano /usr/local/bin/move-and-refresh.sh

Insert this code:

#!/bin/bash
mv /home/user/Downloads/* /mnt/usbdrive/media/
systemctl restart minidlna

Save it: Ctrl + O → Enter → Ctrl + X

Make it executable:

user@homeserver:~$ sudo chmod +x /usr/local/bin/move-and-refresh.sh

Now you can run this script anytime:

user@homeserver:~$ sudo /usr/local/bin/move-and-refresh.sh

8. Schedule this task daily:

Edit your crontab:

user@homeserver:~$ crontab -e

If asked, choose nano as the editor.

Add this line at the bottom:

0 3 * * * /usr/local/bin/move-and-refresh.sh

This will run the script every day at 3:00 AM.

Save and exit: Ctrl + O → Enter → Ctrl + X