If you want to “map a drive” from a Linux computer to a shared folder on a Windows computer or a shared folder on a Linux computer running Samba, there’s a simple way that you can do this from the command line.

Installing Prerequisites

If you are running on Ubuntu or another Debian distribution, you can install the required software by simply running the following command from a terminal prompt:

sudo apt-get smbclient smbfs

Testing the Connection

Now that you have the right tools installed, it’s time to test the connection to the Windows or Samba box with the shared folder. For this we can use the smbclient command like so:

smbclient –L geekmini –U geek

In this example, geekmini is the servername and geek is the username. You’ll be prompted for the password.
You’ll notice that you can successfully see a list of shares on the remote computer. In our case, we want to “map a drive” to the shared folder named “root”.

Create the Mount Point

Any time you want to map a drive in Linux, you should create the folder first. In this case, I want to access that shared folder from /media/Video, so I’ll first need to create the folder.

sudo mkdir /media/Video

Note that I’m using sudo because I’m creating the folder in a system-wide location owned by root.

Actually Mounting the Shared Folder

You can run the following command to mount the shared folder to a local path:

mount –t cifs –o username=geek,password=thepass //geekmini/root /media/Video

Note that you’d want to use your own details in the command. At this point you should be able to access the shared folder from /media/Video

Profile Photo for Lowell Heddings Lowell Heddings
Lowell is the founder and CEO of How-To Geek. He’s been running the show since creating the site back in 2006. Over the last decade, Lowell has personally written more than 1000 articles which have been viewed by over 250 million people. Prior to starting How-To Geek, Lowell spent 15 years working in IT doing consulting, cybersecurity, database management, and programming work.
Read Full Bio »