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.
A test
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
Where:
- IP_TO_SAMBA_SERVER is the IP address of your Samba server.
- SHARE_NAME is the share you want to connect to.
- USERNAME is the user name you connect to the share with.
Enter wallenmusic’s password:
Domain=[MONKEYPANTZ] OS=[Unix] Server=[Samba 3.2.5]
smb: \>
If you see that you can type quit and then hit the Enter key to escape this prompt.
Setup
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
Where:
- IP_TO_SAMBA_SERVER is the IP address of your Samba server.
- SHARE_NAME is the share you want to connect to.
- USERNAME is the user name you connect to the share with.
Automount
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 0Where:
- IP_TO_SAMBA_SERVER is the IP address of your Samba server.
- SHARE_NAME is the share you want to connect to.
- USERNAME is the user name you connect to the share with.
- PASSWORD is the password for the Samba user
umount /data
so you can test your automount entry.
Now, enter the command:
mount -a
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.












