I need to run the following command at startup or upon login to make my samba share accessible to my file system. How can I make this command run when I start my computer?

sudo smbnetfs ~/Shared -o allow_other

Note that this command requires sudo and must be run from a terminal. Putting it in startup applications does not work.

  • Configure sudo to allow you to run that command , smbnetfs, to run without a password. Better, what are you doing exactly ? More likely than not there is a better configuration option. superuser.com/questions/262778/… – Panther Sep 15 '17 at 22:14
  • All I am trying to do is fuse my samba share with my filesystem so apps like Thunderbird and Firefox can browse the samba drive. If I run the sudo smbnetfs ~/Shared -o allow_other command it works perfectly but I have to run it every time I reboot. I'd like to automate this at startup. – Don P Sep 15 '17 at 22:32
  • Try editing /etc/fuse.conf to include the option allow_other see manpages.ubuntu.com/manpages/xenial/man8/mount.fuse.8.html . But how and what user is mounting samba ? should not need to do this. – Panther Sep 15 '17 at 22:39
  • 1
    why not add the share to /etc/fstab ?? I primarily rely on NFS; but I mount my [home] NAS (samba only) backup devices via /etc/fstab (most are ,user so they're not always mounted; but i've had them ,auto before) – guiverc Sep 15 '17 at 22:56
  • 1
    Yes, rc.local was the solution. The reason it didn't work when I tried it earlier is that I needed to make it executable. I solved that issue by running sudo chmod +x /etc/rc.local and now it is working. Thanks for your help. – Don P Sep 15 '17 at 23:19

Create a file: /etc/rc.local

File contents:

#!/bin/sh -e
smbnetfs /home/user/Shared -o allow_other
exit 0

Save the file and make it executable with this command:

sudo chmod +x /etc/rc.local

The commands in the file before exit 0 will be run as root at startup.

Not the answer you're looking for? Browse other questions tagged or ask your own question.