4

On OS X 10.8, using terminal commands, I'd like to enable SMB sharing as if I had ticked the following checkbox under System Preferences - Sharing - File Sharing - Options:

enter image description here

I've tried the following command:

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.smbd.plist

But despite the smb daemon seeming to be up and running, the checkbox is still unchecked, as if something is missing.

The same command works, as an example, for screen sharing (com.apple.screensharing.plist) and even for AFP (com.apple.AppleFileServer.plist), only SMB seem to suffer from this problem.

3
  • Read the small print under the Check box for SMB!
    – Ruskes
    Jul 1, 2014 at 8:56
  • That's a different thing. When I tick the box on System Preferences I don't need to enter passwords or anything else, so there must be a way to do the same with commands without dealing with passwords.
    – Emyl
    Jul 1, 2014 at 9:06
  • On modern systems, it seems the launchctl command is all that's needed. See discussions.apple.com/thread/8463141. May 27, 2019 at 1:17

3 Answers 3

7

I've found the solution. Two commands are needed in sequence:

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.smbd.plist
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist EnabledServices -array disk
1

For others who might be having this same issue with a different root cause, I found that somehow my com.apple.smbd.plist file had gotten corrupt.

You can check this with cat /System/Library/LaunchDaemons/com.apple.smbd.plist. It should appear to be plain text, but if you see a bunch of weird characters, it's probably corrupt.

I simply deleted the file [and after realizing it did not get recreated on reboot] copied my com.apple.smbd.plist from another Mac into /System/Library/LaunchDaemons/. Then I checked the checkbox (or alternately, you could run sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.smbd.plist), and then rebooted.

Problem solved. Same issue, different root cause.

Edit: You should also verify permissions on com.apple.smbd.plist and com.apple.AppleFileServer.plist, especially if copying from a different computer. I discovered that my com.apple.AppleFileSharing.plist file had 777 permission, which was causing it not to load.

Ownership should be root:wheel, and permissions should be 644:

sudo chown root:wheel /System/Library/LaunchDaemons/com.apple.smbd.plist
sudo chown root:wheel /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist
sudo chmod 644 /System/Library/LaunchDaemons/com.apple.smbd.plist
sudo chmod 644 /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist
1
  • Plist has both a textual format and a binary format, and the latter is prevalent in the system. So it doesn't mean at all that the file is corrupt.
    – aaa
    May 2, 2022 at 20:38
1

I came looking for a new approach that would work on macOS 13 (Ventura) and use the modern launchctl syntax. None of the above are working for me.

I'm close with the script below.

sudo launchctl enable system/com.apple.smbd 
sudo launchctl bootstrap system /System/Library/LaunchDaemons/com.apple.smbd.plist 
sudo launchctl kickstart -kp system/com.apple.smbd

It does turn on SMB, and the File Sharing toggle in System Settings does flip to the "on" position. But something isn't right with the smbd daemon permissions when invoked this way. Connections from my iOS devices fail in strange ways, certain directories can't be traversed, etc.

One significant thing I discovered is, when toggling File Sharing on via the GUI, running pgrep -lf smbd yields no results. Some other daemon besides /usr/sbin/smbd appears to be providing the service. But sudo lsof -Pi :445 does not reveal which particular binary has the port open.

I'm hoping someone might be able to build on this and figure out the missing piece.

You must log in to answer this question.

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