How to Mount SMB Share from Command Line on Mac

Feb 13, 2023 - 4 Comments

Mac Terminal icon

Need to mount an SMB network share from the command line of MacOS? There are a few different approaches to mount SMB shares from the command line, and we’ll cover two different methods to mount network shares on the Mac using Terminal.

Many users rely on SMB for file sharing between Mac and Windows PC or Linux, but SMB is also used by many Macs, so you may find a variety of networking situations where you’d want to mount an SMB share. While you can certainly connect to and mount network shares through the Finder, many circumstances exist where performing this action from the command line is necessary or helpful.

We’re going to assume you’re already familiar with the command line enough to know a bit about Terminal, so launch the Terminal app from the /Applications/Utilities/ folder, from Spotlight, or keyboard shortcut, and let’s begin.

Mounting SMB Shares from Command Line on Mac with open

The ‘open’ command will mount an SMB file share in Finder of MacOS, but from the command line. The syntax to use is as follows:

open "smb://name@server/"

For example, if the username was “paul” and the Mac server name was “M1-MacBook-Pro” the command would look like so:

open "smb://paul@M1-MacBook-Pro/"

Hit return and you’ll find the Finder will launch to the network share, prompting you for the password if one is required.

Note: if you’re attempting to use SMB file sharing on a Mac running MacOS Ventura, you may run into error messages repeatedly unless you follow this goofy fix for SMB file sharing in MacOS Ventura which requires you to turn sharing off, reboot, then turn it back on again. File sharing in Ventura is a bit buggy, so don’t be surprised if you encounter issues with it.

Mount SMB Shares from Command Line on Mac with mount

The mount command also allows you to mount a network share from the command line. This will be done entirely from the command line however, and it will not launch the Finder, unlike the aforementioned open command.

The syntax to use with mount for SMB shares is as follows:
mount -t smbfs //name@server /MountDestination

For example, if the user name is “Paul” and the computer name is “M1 MacBook Pro”, and your desired destination is ./mountedM1, the syntax would be as follows:

mount -t smbfs //paul@M1-MacBook-Pro ./mountedM1

Hit return and you’ll have to authenticate (assuming authentication is required) to connect.

You can also place the password in the command for mount, but for security reasons doing so is not advised, since it enters the password in plain text and leaves it in your command history.

Did you successfully mount an SMB share from the command line of your Mac? Do you use another approach to mount SMB shares from the Terminal? Share with us in the comments your methods and experiences.

.

Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS, Tips & Tricks

4 Comments

» Comments RSS Feed

  1. Mike Kirby says:

    Only gives an error “mount: realpath /Users/home/driveName: No such file or directory”.

    It’s been weeks since I was able to mount to remote volume I need mounted to do my work. I sure wish OS X worked.

  2. Gerardo says:

    Thanks, Paul: good tip

  3. NotarySojac says:

    Pardon my ignorance, but what does the dot-slash (./) mean in the final command line?

    • Paul says:

      Great question! Dot-slash ./ represents the current working directory, whereas dot-dot-slash ../ is the parent directory (the directory that holds the current directory)

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site