MacOS – Cannot write to SMB Share with Terminal OS X 10.8

macossmbterminal

I am trying to copy some files from my local drive to a SMB share I have set up on my home network using Terminal, but I keep getting this error:

fchmod failed: Permission denied 

The share is set up on a Freenas server and the folder permissions is set to 777. I can copy the files ok with Finder so I don't know why its not working in Terminal.

Best Answer

The problem here is that terminal is trying to write Unix style permissions to the CIFS share during the copy operation.

When you perform "cp" via terminal the data will transfer but the fchmod command will fail as the "core CIFS protocol does not provide unix ownership information or mode for files and directories".

A few solutions:

  • Mount the share via command line and engage the noperm option to ignore permission errors.

    mount_smbfs -o noperm "//DOMAIN;username@myshare.com/blah" /Volumes/blah
    
  • Alternatively you can use rsync to copy files (without the -a flag)

    rsync -rl source destination.
    

Source: https://www.samba.org/samba/docs/man/manpages-3/mount.cifs.8.html