Macos – How to mount Samba / SMB shares under macOS from a terminal

macosshellsmb

I need to be able mount Samba (SMB) shares from a macOS terminal. How can I do that?

Best 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
Related Question