I'm trying to add the following commands to rc.local:

iptables -A OUTPUT -m owner --gid-owner vpnroute \! -o tun0 -j REJECT

-g vpnroute transmission-gtk

This is to force transmission to only use my vpn and then launch it. Vpnroute group is present and lc.local is owned by root and can be executed. Have also tried to start via lxsessions startup manager with no luck. I've also tried to make a script, chmod it and call it from rc.local.

The script itself can be run without problems from terminal, however nothing happens at startup. Then I tried to make a .desktop file to execute the script, put it in /home/username/.config/autostart, didn't work either.

I added >> /var/log/rc.local.log 2>&1 but there is no log created after startup. If I run rc.local manually I get a log that says /etc/rc.local: 15:/etc/rc.local:-g: not found. If I add sudo to the commands, rc.local executes manually(with password), still not on boot though.

My rc.local:
#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing. sleep 5 sudo 
iptables -A OUTPUT -m     owner --gid-owner vpnroute \! -o tun0 -j REJECT >> /var/log/rc.local.log 2>&1
sudo -g vpnroute transmission-gtk >> /var/log/rc.local.log 2>&1 
exit 0

And the script version, when trying to start it that way:

sleep 3
sudo iptables -A OUTPUT -m owner --gid-owner vpnroute \! -o tun0 -j REJECT
sudo -g vpnroute transmission-gtk

I've changed them both so many times now, to try different suggestions from online forums.

Any help would be greatly appreciated! Best regards Alex

  • This is not the best way to restore iptables rules. Use iptables-persistent, it is in the repos - how to - thomas-krenn.com/en/wiki/…
    – Panther
    Mar 1, 2016 at 12:35
  • @bodhi.zazen Thank you for the link, I stumbled upon this package earlier as well. I realized that I should probably use it instead of doing it this way. But that still doesn't change the fact that I'm unable to run commands in rc.local. Will definitely change the way I change the iptables later.
    – Alex.L
    Mar 1, 2016 at 12:44
  • Well, rc.local has always been a dirty hack and commands can fail for a number of reasons including rc.local running too early. using rc.local will not easily replace proper configuration of lxc or iptables and your post is short on details.
    – Panther
    Mar 1, 2016 at 12:54
  • I'm running Lubuntu and I'm quite new to linux in general, so I'm just looking for a nudge in the right direction. When googling, rc.local came up alot, had no idea it was considered a "dirty hack".
    – Alex.L
    Mar 1, 2016 at 13:18
  • If you want help with your script, post it. I am telling you to properly configure your services, iptables in this case, rather then trying to write an init script. rc.local may work in some limited cases with simple commands, but as you can see it is not a proper init script and it more often then not fails with more complex commands and takes a lot of time and effort to debug. Here is a "simple" guide for converting your script to work properly - 0pointer.de/blog/projects/systemd-for-admins-3.html so you can decide which is less work, iptables-persistent or writing an init script.
    – Panther
    Mar 1, 2016 at 13:22

1 Answer 1


As mentioned already use iptables-persistent for the iptables rule. Regarding starting transmission you should use the daemon that already comes with a rc-service script. So setup the transmission daemon according to the docs Ubuntu docs and enable it:

service transmission-daemon enable

You can access it with the transmission client or on a webinterface depending on your configuration.

You must log in to answer this question.

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