Ubuntu – Mount Samba share allowing users to read/write

mountsamba

I mount a samba share with the following command:

# mount -t cifs //192.168.1.1/username pc -o username=username,password=xxxxx

But only root can go inside that share.

How to allow users read/write in the share?

Best Answer

If only one user needs read/write access, you can make him owner of the mounted directory using the option uid=<linux_username>:

mount -t cifs //192.168.1.1/username pc -o uid=<unix_username>,username=username,password=xxxxx

If more than one user need read/write access, you can create a group, add the users to it:

addgroup new_group
adduser user1 new_group
adduser user2 new_group
adduser user3 new_group

then mount the share using options gid, file_mode and dir_mode:

mount -t cifs //192.168.1.1/username pc -o gid=new_group,file_mode=0664,dir_mode=0775,username=username,password=xxxxx

More information: mount.cifs manual page.