I would like to mount an SMB network share from the command line (terminal); how would I go about that?

I am using Mac OS X 10.6.4.

up vote 54 down vote accepted

You could easily achieve this using mount_smbfs (which is, actually, a wrapper for mount -t smbfs) :

mount_smbfs //user@SERVER/folder ./mntpoint

Optionally, add the workgroup :

mount_smbfs -W workgroup //user@SERVER/folder ./mntpoint

You could, of course, change the ./mntpoint (for something like /Volumes/smb).

After doing this, simply go to ./mntpoint to browse your data.

To unmount, using the following command :

umount ./mntpoint
  • 1
    I get : `mount_smbfs: mount error: path: Input/output error', while it mounts find via Finder->Connect to Server? – Ian Vaughan Mar 2 '12 at 16:53
  • How do I go about it if my username has a @ char in it? For example when i am using a microsoft account like xyz@microsoft.com ? I tried giving the username in single and double quotes but dint work.. – Yashvit Sep 13 '14 at 14:00
  • I get this error: mount_smbfs: illegal option -- W – Iulian Onofrei Nov 4 '15 at 16:32
  • 6
    Quote from man mount on OS X Yosemite: Note: You should always use the system mount command and never call mount_smbfs directly. – ssc Jun 30 '16 at 12:36
  • 2
    @Yashvit: Change the '@' to '%40' – WGroleau Aug 1 '16 at 4:11

Use the open(1) command and a URL:

open 'smb://username:password@server/share'

Pros: Creates the mount point in /Volumes for you.

Cons: Requires the Finder to be running.

  • 3
    i prefer this version for quick connections in my local network, there all users are known, so this is a simpler command then using mount_smbfs - where i actually had problems concerning non existent paths - whereas if i would need to connect to some new server with special filesystem, or i would need to try another user or wanted different mount point - ok - but how often does this happen... so my thumb goes up for this simpler solution! Well Done! Ok i am a Terminal freak who still has Finder running, but that is like 90% of us, right? – hexerei software Sep 12 '15 at 14:00
  • Isn't Finder always opened, at least as a process? – Iulian Onofrei Feb 1 '16 at 8:40
  • 1
    @Iulian Onofrei: Not unless the user is logged in interactively. I've needed to use the direct mount command in cron jobs. Using the open command, these would fail if the interactive session was gone, e.g., after a power failure. – George Feb 9 '16 at 22:21
  • Also, note that open always exits as if it were successful if it passed the command along to Finder, even if the command later failed to connect to the network drive. – Jonathan Wren Jul 17 '16 at 2:15

You should take a look at mount’s help:

man mount

Upon closer inspection you’ll see that the filesystem’s type is:

mount -t smbfs //username:password@MACHINENAME/SHARENAME /SomeLocalFolderOfChoice

Password (and theoretically username) are optional.

The result of the above command will be no output (if all went ok), but a cd /SomeLocalFolderOfChoice, should produce the remote results. Please note that SomeLocalFolderofChoice must exist.

You can also use mount_smbfs to replace the mount -t smbfs.

What worked for me to make them mount during boot:

==> /etc/auto_master <==
# Automounter master map
+auto_master        # Use directory service
/net            -hosts      -nobrowse,hidefromfinder,nosuid
/home           auto_home   -nobrowse,hidefromfinder
/Network/Servers    -fstab
/-          -static
/-          auto_smb          # add this line <**********

==> /etc/auto_smb <==         # Create this if it doesn't exist <****
/(not Volumes)/Public   -fstype=smbfs,soft smb://(user):(password)@
/(not Volumes)/ WGroleau -fstype=smbfs,soft smb://(user):(password)@

For some reason, neither the short name nor the FQDN of the server worked, so I used 'ping (name) to get the IP. In other words, DNS would resolve the name, but mount_smbfs could not.

And I could not put the mount point in /Volumes, because boot up would delete it.

One quirk: After this worked fine for a few days, for two or three days, LibreOffice, Adobe Reader, and Finder could not find ONE of the two shares, but the shell and TextEdit had no problem. After two or three days of that, it mysteriously started working again.

If you do these edits and don't want to reboot, you can mount them with 'auto mount -vc'

Update: More quirks. (1) There are two WiFi systems here, and one of them has no access to the Windows servers. A couple of times a week, one or both of the routers goes down. If the "good one" goes down and the MacBook automatically connects to the other one, instead of telling me the drive is off-line, the SMB drivers say "Too many users." (2) A couple of times a week, I get "permission denied" when I try to access my Windows files. This typically lasts about a half-hour, during which I can go to a windows bar and log in and see files with the same ID and password.

Using AppleScript is convenient because it stores your passwords in the Keychain. Bash function:

function mymount
    osascript <<EOF
mount volume "smb://user@fqdn1/volume1"
mount volume "smb://user@fqdn2/volume2"

Invoke ‘mymount’ from bash, enter passwords via the standard Keychain popup, and if all goes well the requested volumes will be mounted in /Volumes.

I would add that if you have a username of the form "workgroup\username", you should mount it like this :

mount -t smbfs "//WORKGROUP;username:password@MACHINENAME/SHARENAME" /SomeLocalFolderOfChoice

Source : adapting an example from here

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.