I'm rather new to *nix and have played a little with Ubuntu, Mint and now Elementary OS.

I'm doing a mistake but I don't understand where.

I'm mounting a network share via

sudo mount -t cifs //xxx.xxx.xxx.xxx/networkshare /mnt/local -o user=user,password=pass,uid=xxx,gid=xxx

the script is executable, if I run the script in terminal all is ok, it asks the password for root and mount the share

but I would like it to be mounted automatically

I tried to put the command into /etc/rc.local so the #!/bin/bash above it and the exit 0 below it are already there

I tried to put the command into Applications -> Startup Commands

I also tried to create a file.desktop into /.local/share/applications (so, at least, it is easy to run) as Exec I tried both



Exec=sh /path/filename.sh

but none is working, none of the methods is asking me the root password

Surely I'm doing something wrong, I did a google search but I've not been able to find some guide. Can you drive me the right way ?


1 Answer 1


You want to run a script that does not need user interaction so there is absolutely no problem that it does not ask for the root password.

Actually the file /etc/rc.local is run with root user privileges, so it should work (without asking a password). However, the preferred method to mount filesystems automatically is to append them into the file /etc/fstab. There should be a line like this:

//xxx.xxx.xxx.xxx/networkshare /mnt/local cifs user=user,password=pass,uid=xxx,gid=xxx 0 0
  • This IS the *nix way to do a mount at boot ... but you might also want to add an alias for the IP address in you /etc/hosts file and then use the name that you created rather than the IP address in /etc/fstab ... this is assuming the the IP address does not constantly change. You also may want to look at the 'noauto' parameter for use in /etc/fstab if you have mounts that you only want to mount sometimes. 'noauto' just means that you need to issue a mount for that explicitly. Commented May 15, 2017 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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