13

I installed Transmission through a PPA and the daemon starts on boot. I want to change the user that runs the daemon because I want the downloaded files to be under the same user as my XBMC installation, and I can't seem to find where to edit that.

The daemon uses upstart so there is nothing about which users runs it in /etc/init.d/transmission-daemon and there isn't anything in /etc/default/transmission-daemon about the user either

I'm using these ppas for transmission:

/etc/apt/sources.list.d/transmissionbt-ppa-quantal.list:deb //ppa.launchpad.net/transmissionbt/ppa/ubuntu quantal main

/etc/apt/sources.list.d/transmissionbt-ppa-quantal.list:deb-src //ppa.launchpad.net/transmissionbt/ppa/ubuntu quantal main

/etc/apt/sources.list.d/transmissionbt-ppa-quantal.list.save:deb //ppa.launchpad.net/transmissionbt/ppa/ubuntu quantal main

/etc/apt/sources.list.d/transmissionbt-ppa-quantal.list.save:deb-src //ppa.launchpad.net/transmissionbt/ppa/ubuntu quantal main
5
  • Can you please provide the PPA and the version of Ubuntu? Everywhere I looked the transmission-daemon package does have the /etc/init.d/transmission-daemon file.
    – arrange
    Feb 25, 2013 at 21:34
  • Sorry if I wasn't clear, I meant that there isn't anything about which user runs the daemon in that file
    – BvdBijl
    Feb 25, 2013 at 21:35
  • At the start of the /etc/init.d/transmission-daemon file you should see the line "USER=debian-transmission"; that should be it.
    – arrange
    Feb 25, 2013 at 21:38
  • Mine looks like this: gist.github.com/boukevanderbijl/04c7d6a322a08e9629cb
    – BvdBijl
    Feb 25, 2013 at 21:40
  • I added which PPAs I use in the starting post
    – BvdBijl
    Feb 25, 2013 at 21:43

7 Answers 7

18

Since all of the other answers are for Ubuntu pre-systemd, here's an updated guide for Ubuntu 16.04 (from sensecodons.com). Essentially, create a supplementary unit for "transmission-daemon.service" to change the User=... setting and then update that user's "~/.config/transmission-daemon/settings.json" file.

Stop transmission (if it's already running).

sudo systemctl stop transmission-daemon

Create the supplement file directory for transmission:

sudo mkdir -p /etc/systemd/system/transmission-daemon.service.d

Create a new supplement file called "run-as-user.conf".

sudo vi /etc/systemd/system/transmission-daemon.service.d/run-as-user.conf

and put the following text in it.

[Service]
User=codon

Obviously, use your desired username and not "codon".

Tell systemd to reload its units.

sudo systemctl daemon-reload

Next, you'll want to start and then stop transmission to make it create the ~/.config/transmission-daemon/ directory for your new user.

Start transmission and then stop transmission.

sudo systemctl start transmission-daemon; sudo systemctl stop transmission-daemon

You should now have the following directory in your user's home directory: .config/transmission-daemon/

From here, you should be able to update ~/.config/transmission-daemon/settings.json normally.

When you're done, start transmission.

sudo systemctl start transmission-daemon
2
  • 3
    Instead of manually creating that directory and file, use systemctl edit transmission-daemon.service, which will automatically 1. create that directory and file, and 2. when you save and exit, run systemctl daemon-reload as well.
    – muru
    Jan 9, 2017 at 7:35
  • Thanks. Working on raspbian
    – hurelhuyag
    Jan 28, 2021 at 13:58
12

Assumptions:

  • You used this PPA: ppa:transmissionbt/ppa
  • You want to run Transmission with user: some_user and group: some_group

For System V (SysV) init system (eg: Ubuntu 10.04 LTS):

  1. Stop the Transmission Daemon:

    sudo service transmission-daemon stop
    
  2. Edit the init.d scripts

    sudo nano /etc/init.d/transmission-daemon
    

    ...and change USER=debian-transmission to USER=some_user

For Upstart init system (eg: Ubuntu 14.04 LTS):

  1. Stop the Transmission Daemon:

    sudo service transmission-daemon stop
    
  2. Edit the init scripts:

    sudo nano /etc/init/transmission-daemon.conf
    

    ...and edit as follows:

    • change setuid debian-transmission to setuid some_user

    • and change setgid debian-transmission to setgid some_group

For systemd init system (eg: Ubuntu 16.04 LTS):

  1. Stop the Transmission Daemon:

    sudo systemctl stop transmission-daemon.service
    
  2. Create systemd override.conf file:

    sudo systemctl edit transmission-daemon.service
    

    ...and edit as follows:

    [Service]
    User=
    User=some_user
    Group=
    Group=some_group
    

    Notes:

    • This creates the following file: /etc/systemd/system/transmission-daemon.service.d/override.conf

    • The empty variable assignments (eg: User=) are used to clear/reset the value in the existing variable. This seems to be how things are done when using drop-in replacement of the systemd unit file. See: "Example 2. Overriding vendor settings" in systemd.unit manual:

      "...for drop-in files, if one wants to remove entries from a setting that is parsed as a list (and is not a dependency), ... one needs to first clear the list before re-adding all entries except the one that is to be removed..."

  3. Systemd reload and start transmission daemon:

    sudo systemctl daemon-reload
    sudo systemctl start transmission-daemon.service
    

    Note: Unlike with Upstart and SysV init systems transmission-daemon saves all configuration and settings in /home/some_user/.config/transmission-daemon/ instead of /etc/transmission-daemon/settings.json and /var/lib/transmission-daemon

Notes & References


Optional/Additional Information regarding permissions and package updates:

Note: The following is likely only relevant for Upstart and SysV init systems only

Changing Permissions on Transmission's configuration files

If you are not using systemd init system you may now need to change the permissions for Transmission's Configuration files from user=debian-transmission to user=some_user and from group=debian-transmission to group=some_group.

  1. Check the location of your Transmission Configuration Directory. You can find it mentioned in the /etc/default/transmission-daemon file as a line like so:

    CONFIG_DIR="/var/lib/transmission-daemon/info"
    
  2. So assuming your Configuration Directory is /var/lib/transmission-daemon/info, change ownership of configuration files:

    sudo chown some_user:some_group /var/lib/transmission-daemon/downloads
    sudo chown some_user:some_group /var/lib/transmission-daemon/info
    sudo chown some_user:some_group /var/lib/transmission-daemon/info/blocklists
    sudo chown some_user:some_group /var/lib/transmission-daemon/info/dht.dat
    sudo chown some_user:some_group /var/lib/transmission-daemon/info/resume
    sudo chown some_user:some_group /var/lib/transmission-daemon/info/torrents
    
  3. Change ownership of other files:

    sudo chown :some_group /etc/transmission-daemon
    sudo chown some_user:some_group /etc/transmission-daemon/settings.json
    

Extra Information (updating Transmission):

Because you changed the default user you may find that after updating Transmission using the repository (eg: apt-get upgrade) the transmission daemon is no longer running.

Running "sudo apt-get -f install" give the following error:

Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up transmission-daemon (2.84-0ubuntu0.12.04.1) ...
 * Starting bittorrent daemon transmission-daemon
invoke-rc.d: initscript transmission-daemon, action "start" failed.
dpkg: error processing transmission-daemon (--configure):
 subprocess installed post-installation script returned error exit status 255
Errors were encountered while processing:
 transmission-daemon
E: Sub-process /usr/bin/dpkg returned an error code (1)

The reason the daemon fails to start ("invoke-rc.d: initscript transmission-daemon, action "start" failed.") is because we changed permissions from "debian-transmission" to "some_user" and after the update these got reset. So to fix just do the following:

  1. Stop Daemon and Edit config file:

    sudo service transmission-daemon stop
    sudo nano /etc/init.d/transmission-daemon
    

    ...and change USER=some_user to USER=debian-transmission

  2. Re-try fixing update by running:

    sudo apt-get -f install
    
  3. If the update succeeds the Transmission daemon should now be running. You can now follow steps above to change user/group again.

5
  • Fantastic answer, but do you know to change the group on SysV? I see /etc/init.d/transmission-daemon contains USER= but no GROUP=.
    – mpen
    May 12, 2020 at 20:50
  • 1
    Hard for me to test this right now but you could try editing /etc/init.d/transmission-daemon as follows. Add another variable GROUP=some_group in addition to the already existing variable USER=some_user and then change --chuid $USER to --chuid $USER:$GROUP. Also check the start-stop-daemon man page
    – moo
    May 14, 2020 at 22:28
  • Hmm, I tried it and it looks like it's running as both groups now according to grep '^Groups' /proc/$(pgrep transmission)/status, but it's still creating new files as debian-transmission:debian-transmission.
    – mpen
    May 15, 2020 at 2:31
  • I don't think it matters actually. I added my user to group debian-transmission instead and changed settings.json/umask to 2 so now I can move files around without a hitch.
    – mpen
    May 15, 2020 at 3:28
  • This should be the top voted answer! Thank you.
    – Martin D
    Feb 4, 2021 at 19:27
6

This is not the complete story. Apart from changing

setgid <groupname>

and

setuid <username>

in

/etc/init/transmission-daemon.conf

you also need to change the permissions of the config file of transmission-daemon. Otherwise it won't be able to rewrite settings to this file and the daemon will restart until upstart thinks it had enough chances (init: transmission-daemon respawning too fast, stopped)

sudo chown <user>:<group> /etc/transmission-daemon/settings.json
sudo chown -R <user>:<group> /var/lib/transmission-daemon/ 
1
  • Thanks for the bit about changing the permissions of settings.json. Missed that. Mar 27, 2017 at 6:12
4

As of upstart v1.4, setuid and setgid are supported natively in config file:

setgid <groupname>

and

setuid <username>

Before v1.4 you can use this (as described here):

exec start-stop-daemon --start -c {user} --exec {command}
2
2

On systems using systemd, the file you want to edit may actually be:

/etc/systemd/system/multi-user.target.wants/transmission-daemon.service

Follow up editing with:

sudo systemctl daemon-reload

1
  • This is what helped me. I did all other steps but didn't work. Thank you! Dec 26, 2015 at 13:20
2

In Ubuntu 16.04 the startup service was changed from upstart to systemd, making must of the previous answers obsolete. To change the user transmission-daemon runs execute:

Stop daemon:

sudo service transmission-daemon stop

Change ownership of configuration files and "home":

sudo chown -R USER:USER /var/lib/transmission-daemon/*
sudo chown -R USER:USER /etc/transmission-daemon/settings.json

Then edit file /lib/systemd/system/transmission-daemon.service with:

[Unit]
Description=Transmission BitTorrent Daemon
After=network.target

[Service]
User=USER
Type=notify
ExecStart=/usr/bin/transmission-daemon -f --log-debug --config-dir /var/lib/transmission-daemon/info
ExecReload=/bin/kill -s HUP $MAINPID

[Install]
WantedBy=multi-user.target

Please note the User, --config-dirand the --log-debug changes.

Reload systemd configuration:

sudo systemctl daemon-reload

Start daemon again:

sudo service transmission-daemon start

Once you have set the --log-debug (which will give you more information of any issue) option you can get the daemon's log:

sudo journalctl -u transmission-daemon.service

Done.

Things to note:

You can ignore files:

/etc/default/transmission-daemon: It seems that nobody is sourcing it in systemd systems.

/etc/init.d/transmission-daemon: It seems that this was the old system 5 start script.

/etc/init/transmission-daemon.conf: It seems that this is the old upstart start script.

1
  • 2
    Do not edit /lib/systemd/system/transmission-daemon.service manually. Use systemctl edit transmission-daemon.service instead, or your changes will be lost when you upgrade the package.
    – muru
    Jan 9, 2017 at 7:30
0

I did the following, which to me seems less invasive than the other answers.

  1. Remove the startup of transmission-daemon:

    sudo update-rc.d -f transmission-daemon remove
    
  2. Add the following to /etc/profile:

    if [ -f "$HOME/.autostart" ]; then
      $HOME/.autostart
    fi
    
  3. Create ~/.autostart:

    #!/bin/bash
    if [ -z "$(pidof transmission-daemon)" ]; then
     /usr/bin/transmission-daemon --config-dir /home/[USERNAME]/.config/transmission-daemon &
    fi
    

This is a bit more portable perhaps, it works for me on plain Debian and minibian too.

1
  • not a bad idea but it requires that the user logins with a shell that executes /etc/profile (zsh doesn't execute it, for example) Oct 11, 2015 at 9:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .