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?

  • 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 ? Jun 6 '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 6 '20 at 12:22
  • So changing the permissions and ownership of the files and folders did the job ? Jun 6 '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 6 '20 at 14:19
  • Solutions are stated here Jun 6 '20 at 14:25

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.

  • 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 7 '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 7 '20 at 11:11
  • Thanks anyway, but it's working fine and my fstab is playing up anyway
    – ekv_56
    Jun 7 '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 7 '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 8 '20 at 7:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.