Ubuntu – Run terminal sudo command at startup


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.

Best Answer

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.