0

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?

ekv_56
  • 57
  • Do you use samba share ? Please specify this in your post. And your question is a little vague . After mounting the drive , you couldn't write into it in windows or linux ? And how could you change the contents of the folder before mounting it ? – Parsa Mousavi Jun 06 '20 at 12:19
  • @ParsaMousavi Yes, it's a samba share and I can't write it using CentOS after mounting. However, I am researching this link now. – ekv_56 Jun 06 '20 at 12:22
  • So changing the permissions and ownership of the files and folders did the job ? – Parsa Mousavi Jun 06 '20 at 12:45
  • @ParsaMousavi I can't really understand what the exact commands to execute are.... is there any chance, if you know, you could answer and include a couple of commands that will let me allow write access to ALL users for ALL or just that mount. Pref before Monday UK TIME. Thanks – ekv_56 Jun 06 '20 at 14:19
  • Solutions are stated here – Parsa Mousavi Jun 06 '20 at 14:25
  • @ParsaMousavi That hasn't worked for me, not sure how to go from here..... I've tried all the commands suggested on that page and even tried to log in as root and configure permissions through the file browser. No luck...any ideas? – ekv_56 Jun 06 '20 at 14:46
  • @ParsaMousavi What about this link It's very confusing, any chance you could break it down – ekv_56 Jun 06 '20 at 14:49
  • @ParsaMousavi I've updated my question - LINK – ekv_56 Jun 06 '20 at 15:08
  • I'll also have a look here - LINK – ekv_56 Jun 06 '20 at 15:10
  • @jsbillings That's my own question - I need to know how to change write permissions once it's mounted, I've finished with the mounting probllem, that works now. It's just the write permissions in the mounted folder. – ekv_56 Jun 06 '20 at 17:35
  • Yes and I don’t see you putting a uid or gid in the mount. – jsbillings Jun 06 '20 at 18:14

1 Answers1

2

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.

telcoM
  • 96,466
  • Thank you so much, this has worked a treat. I used option one to grant all users access because that didn't matter on my machine. Thank you so much for your help. – ekv_56 Jun 07 '20 at 10:47
  • @ORICKETTS I added an example /etc/fstab entry too. The syntax is tested in a RHEL7.8 system, and it definitely works. I've also added the vers=3.0 mount option to silence the warnings about the changed default version. – telcoM Jun 07 '20 at 11:11
  • Thanks anyway, but it's working fine and my fstab is playing up anyway – ekv_56 Jun 07 '20 at 11:49
  • Do you know anything about rdp to centos machines using xrdp and why this would be happening: link – ekv_56 Jun 07 '20 at 17:22
  • My su thing isn't working so I am going for an fstab mount which isn't working. See here: LINK – ekv_56 Jun 08 '20 at 07:36