I try to mount a samba share with cifs and set write permission to the group on the default file/directory creation mask.
After hours spent searching the web and trying, I can't get this to work, all my files are created with "rw-r--r--" and I want "rw-rw----"

My serveur is a Debian on Cubieboard (Cubian r4)
All umasks of all users are set to 002 using /etc/pam.d/common-session file with "session optional pam_umask.so umask=002"
This works great.

My client is Ubuntu Desktop 64bit 13.10.
All umasks of all users are set to 002 using /etc/bash.bashrc file with umask 002 (because the pam_umask.so doesn't work on the client).
This works great too.

User "bertrand" and group "nas" exist on both the client and the server.
On the server, user "bertrand" has only one group "nas".
On the client, user "bertrand" has "nas" as secondary group.
User bertrand has same password on client, server and samba server.

=> /etc/samba/smb.conf on the server :

server string = %h
map to guest = Bad User
obey pam restrictions = Yes
pam password change = Yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
unix password sync = Yes
syslog = 0
log file = /var/log/samba/log.%m
max log size = 1000
name resolve order = lmhosts host wins bcast
dns proxy = No
wins support = Yes
panic action = /usr/share/samba/panic-action %d
idmap config * : backend = tdb

comment = NAS drive
path = /media/usbnas
valid users = @nas
force group = nas
read only = No
create mask = 0660
directory mask = 0771

=> /etc/fstab on the client:

//smbserver/nas /media/nas      cifs    uid=bertrand,gid=nas,credentials=/root/.smbcredentials     0     0

The .smbcredentials contains:


The mounting point works on my client, I can browse my nas, create, delete, modify files and directories but all new files and all new directories always has read only permission for group.

How to give group write permissions by default ?


1 Answer 1


Can you try to add mount option file_mode=0770,dir_mode=0770.

  1. Try to modify /etc/fstab file:

    //smbserver/nas /media/nas      cifs    uid=bertrand,gid=nas,credentials=/root/.smbcredentials,file_mode=0770,dir_mode=0770     0     0
  2. Or, mount command

    sudo mount -t cifs //smbserver/nas /media/nas -o uid=bertrand,gid=nas,rw,credentials=/root/.smbcredentials,file_mode=0770,dir_mode=0770

My test environment:

OS version: Ubuntu 10.04.4 LTS
kernel version: 2.6.35-25
mount.cifs version: 1.12-3.4.7
samba version: Version 3.4.7
  • if my answer is right, can you give me any help about my question?
    – user221594
    Dec 4, 2013 at 5:18
  • my quetion is askubuntu.com/questions/385317/…
    – user221594
    Dec 4, 2013 at 5:19
  • Very helpful! While file_mode and dir_mode are explained clearly on the cifs manpage, the arguments that they accept are not. In particular, the full octal representation is required! That is, 755 will yield "garbled" permissions such as d????????? ? ? ? ?, whereas 0755 will work as expected. Dec 10, 2018 at 21:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .