Permissions – Fix CIFS Mounted NAS Box Permission Issues

permissionssamba

I'm running the latest version of Ubuntu, and have mounted a SMB share via a line in rc.local.

The share mounts correctly, and I can browse files freely, create new files, and then delete them without problems.

But when I try and rsync a directory onto the mounted share:

rsync -a --delete /MySource/ /SharedMountPoint/

I get lots of errors:

rsync: failed to set times on "/SharedMountPoint/SomeDir": Operation not permitted (1)

and similar errors about being unable to create temp files.

All the files and directories on the share are listed with numeric uid/guid – which I suppose is reasonable, as they were originally created via a sync from a windows box.

I have no great need for access control – its just a box on a LAN that me and my family use as a dropbox – I'd basically just like anyone to be able to access it (provided they've done basic authentication).

Best Answer

When mounting, use -o uid=youruid. Then, all files on that cifs share will be owned by you so that you can edit/remove them.
E.g.:

mount -o uid=1000 //nas/share /SharedMountPoint

You can find your numeric uid in /etc/passwd

grep `whoami` /etc/passwd | cut -d : -f 3

or:

id -u `whoami`
Related Question