Methods for Mounting Samba Shares Andrew Mallett | Posted February 2015

The Samba software suite is a collection of programs that implements the Server Message Block (commonly abbreviated as SMB) protocol for UNIX systems. This protocol is sometimes also referred to as the Common Internet File System (CIFS) and allows other systems such as Windows and Android to connect to shared directories.

There are a number of ways to mount samba shares. In the following examples sharename is the name of the shared directory on the remote Samba server and mountpoint is the name of the local directory which the remote share will be mounted to. Variations on the method are also included and may need to be experimented with.

Note that Linux Mint and similar distros have dropped smbmount support in favour of CIFS. See installing cifs instead of smbmount.


Listing a shared directory

smbclient -L ipaddress -U username

smbclient //ipaddress/sharename -U username


Mounting an SMB share using the smbmount command

smbmount //ipaddress/sharename /mountpoint -o username=name,workgroup=name


Mounting an SMB share using the mount command

mount -t smbfs ipaddress:/sharename /mountpoint -o username=name,workgroup=name

mount -t smbfs //ipaddress/sharename /mountpoint -o username=name,workgroup=name


Mounting an SMB share using the mount cifs command

mount -t cifs ipaddress:/sharename /mountpoint -o username=name,workgroup=name


Mounting an SMB share including the password

mount -t smbfs -o username=name,workgroup=name,password=pwd //ipaddress/sharename /mountpoint


Mounting an SMB share by editing fstab

vi /etc/fstab//ipaddress/sharename /mountpoint smbfs rw,user,username=name,password=pwd 0 0

Save and exit the file and then confirm the mount using the following commands..

mount -a

df -H

If the systems are running on a Domain, use the domain user's username and password.

Note that this method raises security concerns due to fstab being readable by all users. A workaround is to put an .smbfile in the user's own home directory containing their username and password.

cd ~
echo username=name > .smbfile
echo password=passwd >> .smbfile
chmod 600 .smbfile 

Then run the command to point to the .smbfile for the user credentials..

vi /etc/fstab //ipaddress/sharename /mountpoint smbfs credentials=/home/userhomedir/. smbfile,rw,user 0 0 


Mounting without a passsword prompt using mount_smbfs

It's not over yet! Another variation on the above uses mount_smbfs to mount a password-protected samba share without being prompted for a password. This is useful for automated scripts. See Mount Samba Shares Without a password Prompt.


UnMounting shares

Piece of piss, mate..

umount /mountpointdirname

Sharing files using NFS

The Network File System provides a way to share directories under Unix operating systems in a similar way to Samba. See File Sharing with NFS on Linux.