Here are my steps:

mkdir /mnt/docs
chown www-data:www-data /mnt/docs
ls -l /mnt

Positive results:

drwxr-xr-x 2 www-data www-data 4096 Jan  6 01:14 docs
drwxr-xr-x 2 root     root     4096 Dec  8 21:46 cdrom

Now I mount the remote share successfully (I can touch files to it as root) like so

mount -t cifs // -o username=****,password="****" /mnt/docs
ls -l /mnt

Negative results (the owner is back to root):

drwxr-xr-x 2 root root    0 Jan 12 02:51 docs
drwxr-xr-x 2 root root 4096 Dec  8 21:46 cdrom

I then tried to chown the symlink like so (with -h)

chown -h www-data:www-data /mnt/docs
ls -l /mnt

But the results are still

drwxr-xr-x 2 root root    0 Jan 12 02:51 docs
drwxr-xr-x 2 root root 4096 Dec  8 21:46 cdrom

How can I mount the share to a local mount point as a non-root user? The goal is to let Apache be able to write to the remote share. Solutions for either Debian or CentOS systems are appreciated. Also, chmod as no effect either.

Related: Symbolic link creation failing: change ownership issue

  • use chown -R www-data:www-data for recursiveness – answerSeeker Jan 13 '17 at 2:16
  • But, without -h then the target gets chown'd, not the symlink. Also, it's an empty directory. Thanks. – Drakes Jan 13 '17 at 2:20
  • I think it has something to do with the way you created your samba share. If you follow this guide: help.ubuntu.com/community/…! maybe it'll help – answerSeeker Jan 13 '17 at 2:25
  • Is your samba share created on ubuntu or debian? – answerSeeker Jan 13 '17 at 2:31
  • I'm not sure where it resides. It's on a Linux machine that I can't SSH into. – Drakes Jan 13 '17 at 2:59

I'm not sure what symlink you are referring to. What you fail to change is the owner of /mnt/docs, the mount-point of your CIFS share. The mount-point owner changed to the user who mounted something onto it (root).

Since only root is able to mount, how can you change the owner of the mount-point (and its underlying content)? With the uid and gid options (and also, if necessary, the forceuid and forcegid options).

See the man-page of mount.cifs:


sets the uid that will own all files or directories on the mounted filesystem when the server does not provide ownership information. It may be specified as either a username or a numeric uid. When not specified, the default is uid 0.

Therefore, your mount command should be:

mount -t cifs \
      -o username=****,password="****",uid=www-data \
      // \

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.