Mountain Lion File Sharing via Terminal

SeanBurke
New Contributor

Hey Guys,

Probably a dumb question - but was looking for a way to enable File Sharing (both AFP and SMB) consistently for Mountain Lion via a script or terminal (or config profile, any method that would turn it on). I know the Resource Kit contains a script, but it doesn't seem to enable the LaunchDaemon without the -F flag which I believe would need to happen at each login.

I tried changing the Disabled key to false within the com.apple.AppleFileServer.plist but that didn't seem to stick.

Probably over-thinking this.

Thanks for any suggestions!

1 ACCEPTED SOLUTION

talkingmoose
Moderator
Moderator

Just realized you were speaking about modifying the "Disabled" key. No need to do that. Add the "-w" flag to your command. It's purpose is to toggle that key:

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

or

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist

View solution in original post

10 REPLIES 10

nessts
Valued Contributor II

if you change the flag, you will have to load the daemon
launchctl load /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist to start it after you enable it.

SeanBurke
New Contributor

Changed the Disabled key to false in com.apple.AppleFileServer.plist and tried launchctl load /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist but I'm receiving the same error I was getting before: "nothing found to load"

talkingmoose
Moderator
Moderator

Try unloading first and then loading after that.

Actually, I'd unload, modify and then load just to keep things clean.

SeanBurke
New Contributor

Still a no go. I can't unload as there isn't anything to unload (Error unloading, even with a -F). I modified the <key>Disabled</key> from <true/> to <false/> , rebooted, and ran the launchctl load /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist again. Still receiving the same error - "nothing found to load". Is there another file that needs to be modified? Do you have a specific set of instructions I could follow? I've tried monitoring for system changes with Composer but I'm not able to locate anything definitive.

mm2270
Legendary Contributor III

Are you doing the command as sudo?

talkingmoose
Moderator
Moderator

Just realized you were speaking about modifying the "Disabled" key. No need to do that. Add the "-w" flag to your command. It's purpose is to toggle that key:

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

or

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.AppleFileServer.plist

SeanBurke
New Contributor

Awesome! Thanks for the info, I figured it was something easy that I was missing. I'm assuming enabling SMB under file sharing is similar, just call com.apple.smbd instead?

talkingmoose
Moderator
Moderator

Appears that works even though it doesn't seem to activate the File Sharing option in System Preferences. Haven't thoroughly tested. This isn't a setting I need to manage in my environment.

rgibbonz
New Contributor

Bill Saved the day again!

Thanks Bill.

talkingmoose
Moderator
Moderator

@rgibbonz BOBBEEEEEEE!

Oh, geez, like more than four years later you find this? You got your CCT too!