I have a Windows 7 host, with a CentOS 6 guest under VirtualBox.

I have a Windows directory shared with the Linux guest using CIFS.

Everything worked fine so far, until I realized that all chmod operations yield:

chmod: changing permissions of `x': Operation not permitted

This is understandable, but my problem is that some tools I have no control on, attempt to chmod files for me, and fail as a result.

Is it possible to allow but ignore all chmod() calls on a CIFS mount? Please note than these calls are made from a programming language and not from the command-line chmod utility.

Edit: the manual for mount.cifs says (emphasize mine):

The core CIFS protocol does not provide unix ownership information or mode for files and directories. Because of this, files and directories will generally appear to be owned by whatever values the uid= or gid= options are set, and will have permissions set to the default file_mode and dir_mode for the mount. Attempting to change these values via chmod/chown will return success but have no effect.

That's exactly the behaviour I'm after then, so why is it not working for me?

  • Please could you clarify what programming language, and what you are actually trying to achieve with the programming language. Allow but ignore on the face of it seems to be contradictory. With further background will help us provide insight into your problem.
    – David
    Apr 21, 2014 at 21:55
  • I don't think you can get all permissions modifications to be ignored . . . does the script actually bail out when the file permissions are modified, or does it bail out later as the permissions are not sufficient? If they're not sufficient, you could use mount options (file_mode and dir_mode) to set all the files to have the permissions you need . . .
    – ernie
    Apr 22, 2014 at 0:21
  • @David Again I don't have control over the tool, which I believe is programmed in C, and makes calls to the system's chmod() function. @ernie It bails out when the file permissions are (trying to be) modified, and does not complete.
    – BenMorel
    Apr 22, 2014 at 6:31
  • For information, I'm trying to install a PEAR package for PHP over Composer, and the script fails because its PHAR package installer tries to chmod() some files. The exact error is: Extraction from phar "..." failed: Cannot extract "package.xml" to "...", setting file permissions failed.
    – BenMorel
    Apr 22, 2014 at 6:35
  • Thanks, this was the background that we where looking for. Can you add additional permissions on your Windows system to permit what is happening in the install script? It sounds almost as though the script is trying to set something to executable, which just may not work on a windows share.
    – David
    Apr 22, 2014 at 9:17

2 Answers 2


Found it: the noperm mount parameter does exactly this:

// /mnt/www cifs noperm,username=www,password=xxx, ...

Note that mount -a does not apply the parameter, you have to reboot to make it work.
It took me a lot of trial and error to figure this out.

Now chmod works fine, the command does not yield any error, and is just ignored.

  • 2
    Why reboot when you can just unmount and mount again? Maybe CIFS can even remount.
    – Daniel B
    Apr 25, 2014 at 11:44
  • Shouldn't mount -a unmount and remount as well?
    – BenMorel
    Apr 25, 2014 at 11:50
  • No. That would be fatal. It only mounts currently unmounted filesystems from /etc/fstab
    – Daniel B
    Apr 25, 2014 at 12:41
  • This fixed the problem I was having using python's shutil.copytree(src,dst) where dst is on a CIFS mount. Internally, shutil's low-level copy function does a chmod on dst after the copy. The solution here is much preferred to catching and ignoring the [Errno 1] Operation not permitted that python was producing. Dec 18, 2019 at 18:35
  • Thanks this worked great for a program that was out of my control trying to change permissions on a CIFS mount
    – rwarner
    Sep 22, 2021 at 21:46

Try adding exec option. I believe mounting as a non-root user will turn off exec.


  • Same thing I'm afraid with exec: operation not permitted.
    – BenMorel
    Apr 24, 2014 at 13:02
  • try mounting as root?
    – David
    Apr 24, 2014 at 22:17
  • Well, looking at a couple further articles, you can not chmod +x to a file on a windows share. You have marked all the files as executable by using using the option file_mode=0777 anyway. I would suggest installing the pear module on a folder in the linux file system, then copy it over.
    – David
    Apr 24, 2014 at 22:24

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.