So you have that Samba server up and running and you can connect to it from Windows and Mac with ease. But when you turn to another Linux box that doesn't have Konqueror, Nautilus, or Dolphin you can't figure out the riddle of connecting. Or maybe you want to have this share mounted at boot time? How do you manage it?
From the command line of course. Yes there are plenty of GUI tools that will allow you to connect to a Samba share easily, but they don't help you set up anything to connect automatically. For that you will need to employ a few command line tools. But once it is finished, your system will be seamless.
What you will need
First I am going to assume you have your Samba server set up and you are able to connect to it from other machines. Outside of that you will need only one piece of software installed on your Linux machine: smbclient. This will be in your distributions' repositories so just open up your Add/Remove Software utility, search for smbclient, select it, and click Apply.
Once smbclient is installed you are ready to go.
Let's first test to make sure your Linux box can see the Samba share. You will need either sudo or root access to do this. Issue the command:
smbclient //IP_TO_SAMBA_SERVER/SHARE_NAME -U USERNAME
If all is well you should see something like this:
Enter wallenmusic's password:
Domain=[MONKEYPANTZ] OS=[Unix] Server=[Samba 3.2.5]
If you see that you can type quit and then hit the Enter key to escape this prompt.
The first thing you need to do is create a directory to mount the Samba share to. I created the directory /data with the command:
sudo mkdir /data
Once that directory is created you can then mount it with the command:
mount -t smbfs -o username=USERNAME //IP_TO_SAMBA_SERVER/SAMBA_SHARE /data
Now if you check the /data directory you should see a listing of the contents of the Samba share.
Let's make that share automount at boot. This will require editing your /etc/fstab file, adding an entry for this Samba share. In this file (again you will have to have either root or sudo access) you will add a line like this:
//IP_TO_SAMBA_SERVER/SAMBA_SHARE� /data smbfs username=USERNAME,password=PASSWORD, 0 0
Once that entry is saved unmount the /data directory with the command:
so you can test your automount entry.
Now, enter the command:
If there are no errors you should see the contents of the Samba share in the /data directory.
That's it. Congratulations, you now have an automounted Samba share on your Linux machine.
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.