I need to be able mount Samba (SMB) shares from a macOS terminal. How can I do that?
1 Answer
Just like you would do in any common *nix system, you first have to create a directory which will serve as the mount point:
mkdir -p ~/some/folder
Then mount the SMB share:
mount_smbfs //host/share ~/some/folder
If your server requires a username, password, and a domain:
mount_smbfs //domain;user:password@host/share ~/some/folder
Of course you can also leave out the password, and mount_smbfs
will prompt you for it:
$ mount_smbfs //user@host/share ~/some/folder
Password for host: …
Check out man mount
for a list of common options to pass to the -o
switch. For storing authentication, see nsmb.conf
.
To unmount, just call:
umount ~/some/folder
-
Thanks a lot. It's really helpfull. I'm just new in MAC OSX and Cocoa. What I need is to create some user, and enable SMB sharing on that user, so it will be accessible only for that user (make that user hide if possible) Is it possible to do?– User1234Oct 9, 2011 at 0:30
-
I tried but it won't work for me. I need to mount SMB for user, like you can do it from System Preferences, with choosing users.– User1234Oct 10, 2011 at 11:04
-
@User1234 What do you mean? Which "SMB for user"? What does "mount SMB for user" mean, exactly? From System Preferences, you can enable a SMB share, which will be available to the network, not mount it.– slhckOct 10, 2011 at 11:06
-
I will try to explain , what I want. I need help really ASAP. And I'm new in all this bash commands. I want to create user from APP (hidden if possible ) and after share folders (already know how to do it from terminal) . After I want to enable SMB sharing on that user account. So server, can access my shared folders, with that user, that I created. Help is really appreciated Thanks– User1234Oct 10, 2011 at 11:10
-
@User1234 Then this is the wrong question – here, I explained you how to connect to a given share, not how to enable it. Finally you explained your real situation to me, so thank you for that. You already asked that question here: How to enable User Account SMB sharing from terminal on MAC OSX?– slhckOct 10, 2011 at 11:13