I have a network drive service hosted on Samba(Whose settings I can't change) when I mount it on my ubuntu pc using mount.cifs I am able to read write it's content. To make a directory or file there using sudo only(My current user have sudo rights).

Mount command used is: sudo mount.cifs //address.to.samba /mnt/temp -o"username=user,password=pswd"

When the network drive is mounted on /mnt/temp/, in my php program file_exists(/mnt/temp/) returns True where as is_writable(/mnt/temp/) returns false.

The permission of /mnt/temp is initially 755. But even if I do chmod to 766 for the directory it dosen't change.

what shall I do ?

  • You should say how you are running this php, and who you think it is running as. Example: is this phone invoked as part of a web interface.
    – user459652
    Jan 4, 2019 at 8:01
  • @jdv I am running an apache server to host the php and the php is running becouse if I save it elsewhere it works fine and as well as all other things in php gives output Jan 4, 2019 at 8:50
  • -o 'uid=...,gid=...,file_mode=...,dir_mode=...,username=...,password=...'. See the manual page for mount.cifs for details.
    – AlexP
    Jan 4, 2019 at 9:36
  • Thank you @AlexP It works. only if we set the dir_mode=777. please write it as a answer it will help others as well. Jan 4, 2019 at 9:54
  • @ShaleenJain always edit the question when adding requested details. Neither question details nor answers should be hidden in comments.
    – user459652
    Jan 7, 2019 at 16:07

1 Answer 1


CIFS filesystems get their owner and group from parameters of the mount command:

mount -t cifs -o 'uid=...,gid=...,file_mode=...,dir_mode=...,credentials=...'

See the manual page for mount(8) for details.

You probably want to mount the filesystem with the uid/gid under which the Apache HTTP server runs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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