0

The goal is to write to a synology NAS without sudo. SAMBA permissions are read / write with the user mySambaName. Mount command required sudo:

sudo mount -t cifs //192.168.x.y/home /home/username/nas -o username=mySambaName

Reading from the mounted directory returns the contents of the NAS, however, my observation was that sudo is required to write a text file:

sudo vi /home/username/nas/text.txt

The command chown -c username:username /home/username/nas

failed to change the owner/group from root to username.

What needs to be done be able to write without sudo permission?

Is the solution to somehow not use sudo to mount and somehow configure /etc/fstab?

gatorback
  • 6,523

1 Answers1

1

CIFS - as in mount.cifs - creates a virtual filesystem on the client and by default will mount with owner=group=root with permissions of 755. Only root has write access.

mount.cifs gives you the ability to change ownership or permissions - on the client - to anything you want.

SO you can replace root as owner to you by using the uid option, for example:

sudo mount -t cifs //192.168.x.y/home /home/username/nas -o username=mySambaName,uid=1000

If your uid on the client is 1000. Run id to verify

You can also use your linux login user name instead of 1000. So for me ( morbius ) if would be:

sudo mount -t cifs //192.168.x.y/home /home/username/nas -o username=mySambaName,uid=morbius

Either way now I as owner can write to the mounted share.

There are many options available to you. You could for example go to the opposite extreme and make it writeable to everyone on the client machine:

sudo mount -t cifs //192.168.x.y/home /home/username/nas -o username=mySambaName,uid=morbius,nounix,dir_mode=0777,file_mode=0666
Morbius1
  • 8,437