Apple Intelligence now features Image Playground, Genmoji, Writing Tools enhancements, seamless support for ChatGPT, and visual intelligence.

Apple Intelligence has also begun language expansion with localized English support for Australia, Canada, Ireland, New Zealand, South Africa, and the U.K. Learn more >

You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Enable and disable file sharing from terminal

Is there a way to enable and disable file sharing from the terminal?


I'm not able to connect to the share after a reboot. Apples forces me to disable and enable the file sharing service in the system preferences by hand.


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

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


and also killing the smb process (will start again) doesn't work.


Any ideas? Back to 10.5 or so? 😉 It's really hard to see that apples samba is getting worser and worser with each release.


Using the terminal would allow me to apply this "fix" automatically on a restart.

OS X El Capitan (10.11.3), Finder, NAS, shares

Posted on Jul 15, 2018 1:32 AM

Reply
Question marked as Top-ranking reply

Posted on Jul 15, 2018 5:27 AM

On macOS High Sierra 10.13.6, the following legacy launchctl commands have been tested to enable/disable filesharing for their respective protocol. The sudo command is the key to success. No reboot or logout necessary.


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

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


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

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


The System Preferences : Sharing panel will not show the status of File Sharing in real time when you run these commands. If you have this panel open, after starting the SMB, you must first click on the Options… button to see that indeed, Share files and folders using SMB is selected. When you click Done on that sheet, then you will see that the main File Sharing is now also selected. Same approach when you disable SMB from the command line.

Similar questions

5 replies
Question marked as Top-ranking reply

Jul 15, 2018 5:27 AM in response to Xairoo

On macOS High Sierra 10.13.6, the following legacy launchctl commands have been tested to enable/disable filesharing for their respective protocol. The sudo command is the key to success. No reboot or logout necessary.


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

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


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

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


The System Preferences : Sharing panel will not show the status of File Sharing in real time when you run these commands. If you have this panel open, after starting the SMB, you must first click on the Options… button to see that indeed, Share files and folders using SMB is selected. When you click Done on that sheet, then you will see that the main File Sharing is now also selected. Same approach when you disable SMB from the command line.

Jul 15, 2018 5:06 AM in response to Xairoo

I'm not able to connect to the share after a reboot. Apples forces me to disable and enable the file sharing service in the system preferences by hand.

Perhaps there is something interfering with your Mac. My file sharing (SMB) still runs after a restart.


This is from long ago, but perhaps some of the fixes in the comments might help: terminal - Enable SMB sharing from command line - Ask Different

Jul 15, 2018 5:34 AM in response to VikingOSX

Thanks for hint with the panel, I could get the current status when I just reopen the system preferences.


But the strange thing: Running launchctl (unload and load and both AppleFileServer and smbd) will restart the service, but restarting it using the system preferences panel will "work".

I'm using my iPad to open a shared folder with an app using smb. launchctl didn't worked, have to disable and enable the file sharing service checkbox inside the panel to get a working connection (otherwise I can't see any files).

Is there a way for a complete reset? I'm also wondering why I could sometimes (!!!) all of my volumes as a shared folder on the client. Why?! I just have 1 share - a simple folder, far away from / and deep located inside a volume.

Enable and disable file sharing from terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.