Connecting to SMB shares from the command line in OS X


I’ll keep this one short for brevity. It’s sweet and simple. If you’re anything like me you’re probably using at least 10 different operating systems at once. Well, that might be a slight over exaggeration, but I certainly use at least three in my home. Here’s the problem that I faced this evening and how I overcame it.

I have a linux server which is sharing some data using a samba share (SMB). Connecting to this from my windows box is simple, since microsoft is good enough to make mounting shares over SMB a piece of cake. My MacbookPro running OS X Lion, however, was a different story.

One option is to use the finder to manually connect to the share, but since I often connect to various computers using SSH I wanted to find a purely command-line solution. Thankfully, it’s super simple. Just use the UNIX command mount – as follows:

mount -t smbfs //<username>@<ip or fqdn>/<share name> <mount point>

The example of this on my network is as follows:

mount -t smbfs //james@ /Users/jamesanslow/linuxserverfiles

Note: you will require smbfs + samba installed + configured for this to work (duh?)

Posted Wednesday, October 19th, 2011 under ICT.
  • Foren

    My question is: How do you access shares that you mounted with Finder, at the command line?  They’re not listed under /Volumes.

    • andylockran

      Type df in a terminal and you should see where they are mounted.

    • Jamesanslow

      Hi Foren,

      If you open up the terminal and enter the command ‘df’ you will see a list of all of the devices mounted on your system. Under the ‘mounted on’ column, you should see the shares physical path.