Do you need to access and mount an SMB share from the command line on a Mac? You may be used to connecting to Windows PC from the Mac networking features to mount a Windows share on Mac, but you can also connect to Samba shares from the Terminal too.
This article will show several ways to mount and access SAMBA / SMB network shares from the command line of Mac, including with the latest MacOS versions and older Mac OS X releases too, as the process is different depending on the system you are using.
How to Access & Mount SMB Shares via Terminal on Mac
In newer macOS versions, you can can accomplish this with “mount_smbfs” command and it’s rather simple:
mount_smbfs //USER@192.168.0.105/myshare /mnt/smbshare
Replace USER, the IP address, the share name, and the share mount point, and that’s all there is to it.
Of course you’ll have to login and authenticate to the network share, unless it’s a GUEST user login.
You can also unmount the SMB share with the ‘unmount’ command as usual.
Accessing & Mounting SMB Shares in Older Mac OS X Versions
For older versions of Mac OS X, OSXDaily reader Dan Luna sent in the following tip on accessing Windows shares on the Mac from the command line:
“My Mac is nestled into a sea of Windows PC’s at the office, and so I am frequently accessing SMB shares to share data and files. Accessing SMB/Windows shares on the Mac is really easy from the GUI but I spend a lot of time in the command line and I always like to find a way to do things using the underpinnings of Mac OS X. With this in mind, here’s how to access SMB shares via the command line in Mac OS X:”
Earlier versions of Mac OS X could break this into several commands like so, to first list the available SAMBA shares at the destination IP:
smbclient -U user -I 192.168.0.105 -L //smbshare/
(Note that some of the newer versions of OS X use “smbutil” instead of smbclient)
Now you’ll want to pass set your SMB shares mount point:
mount -t smbfs -o username=winusername //smbserver/myshare /mnt/smbshare
And finally you’ll want to gain access to the SMB share by specifying your Windows login and the machines IP address:
mount -t cifs -o username=winusername,password=winpassword //192.168.0.105/myshare /mnt/share
Thanks for the tip Dan! I haven’t been able to check if this works because I’m on an all Mac network with later Mac OS releases, but the commands seem valid so I see no reason it wouldn’t.
Obviously you’ll need to fill in your own unique usernames, sharenames, IP addresses, mount points, etc.
I really appreciate Dan’s tip and it’s a great advanced trick to use for terminal users, but for some Mac users who prefer the GUI then mounting Windows shared folders through Mac Finder is probably easier.
Follow Me:
Top Best Sellers!!