I’ve got a samba share hosted on a Windows 10 PC and I have mounted it via a script that is set to automatically run on startup (my fstab wasn’t working right) and the script looks like this:
sudo mount -t cifs //ipaddress/sharedfoldername /mount/location --verbose -o credentials=/credentials/file/location
When I access the mount location folder before the mount, I have full write access as a standard user. However, after mounting, root becomes user and I have no write access. I have tried multiple commands including all on this link. I have also tried logging in as root and changing file and folder permissions through my file browser (Caja). I am running CentOS7 and need a simple set of commands to use to set write access to all standard users on either all mounts or specific mounts that can be chosen. I have also set the share to allow ‘Everyone’ to access when sharing on the Windows PC. So when the share is mounted, the standard user can view and open files, just not create, delete, edit and save files.
Does anybody have any ideas?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
To grant full read&write access to everyone, you’ll need to change the mount command to:
sudo mount -t cifs //ipaddress/sharedfoldername /mount/location --verbose -o credentials=/credentials/file/location,file_mode=0666,dir_mode=0777,vers=3.0
Note that there are no spaces after the commas – that is important here.
To specify this mount in /etc/fstab, the line should look like this:
//ipaddress/sharedfoldername /mount/location cifs credentials=/credentials/file/location,file_mode=0666,dir_mode=0777,vers=3.0 0 0
Alternatively, you could create a group with sudo groupadd <groupname>, add users to it by running sudo usermod -a -G <groupname> <username> for each user you wish to add into the group, and then use it in your mount command like this:
sudo mount -t cifs //ipaddress/sharedfoldername /mount/location --verbose -o credentials=/credentials/file/location,file_mode=0660,dir_mode=0770,gid=<groupname>
You could create a different group for each mount if you wish to manage access separately for each mount. Members of the group will have full access; non-members will have no access at all.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0