Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use gvfs script to mount my SAMBA share when my system starts. I run it at autostart. Here is the script:


sleep 4

   wifi="'$(/sbin/iwconfig eth1 | egrep ESSID | cut -d '"' -f 2)'"

      if [ $wifi = "'deckoff'" ]; then 

 gvfs-mount smb://

end script

It works great, but when network is down I have to manually re-connect. I added the same script to /etc/network/ifup.d, and as I expected, I am getting a warning

Could not change permissions for

I suspect the reason is that the script that re-mounts at reconnect is run as sudo. So, ideally, I want a solution that runs the script every time network is connected as user. I will be happy if I get rid if the warning at the very least.

share|improve this question

I fixed it this way:


I decided to use cifs


Added this script to /etc/network/if-up.d


WL=$(iwconfig wlan0 | grep wlan0 | cut -d':' -f2)

if [ $WL == '"yournetworkname"' ]
echo "deckoff"
sudo mount -t cifs // /media/MyBookLive -o username=user,password=pass,uid=1000,nobrl,iocharset=utf8,codepage=unicode,unicode


The name and the type of the wifi (wlan0) in my case should be changed to yours. The type can be seen with the command iwconfig


sudo visudo 

This command will let you mod which commands could be executed without sudo rights, by which users etc.


deckoff ALL = NOPASSWD: /bin/mount
deckoff ALL = NOPASSWD: /bin/umount

This will let deckoff mount and umount drives without sudo rights


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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