Connecting to SMB shares from the command line in OS X

October 19th, 2011 by andylockran Leave a reply »

 

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@192.168.0.4/james /Users/jamesanslow/linuxserverfiles

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

Advertisement
  • http://profiles.yahoo.com/u/XTEHYKVLUGE3RDDI7BARRUA4WM Foren

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

    • http://zrmt.com 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.