Mounting a Samba Share in Ubuntu Linux Automatically

Samba shares allow users to stores file on a network. Storing files on a network reduces redundancy as the data stored can be accessed from multiple computers. Samba is an open source software that provide linux users to access windows directory and even connect to active directory components.

Samba can be installed on linux systems and can be used as to share folders, drives over the network.


Here is a step by step guide to mount samba in Ubuntu Linux. After completing this step by step procedure you need to add a special entry which mounts the samba folders automatically every time automatically when you reboot your ubuntu linux.

Step1.)Install the samba client on your ubuntu linux.

sudo apt-get install smbfs

Mounting a Samba Share in Ubuntu Linux Automatically

Create a folder where you want to mount the samba share. Data is name of folder where i want to mount my samba share

mkdir /home/newtrojan/Data

Step2.)If your samba share is protected by a password you need to create a credential file. You can create the file in root directory or your home directory. In my case my home directory is newtrojan.

sudo gedit /home/newtrojan/.cifscredentials

username=yourusername
password=samba password

now save the file.

Now to automatically mount the samba share you need to edit the fstab file.
Note:- it is better to make a backup of the fstab file first.

sudo cp /etc/fstab /etc/fstab.backup

Step3.)now add the following entry to the fstab file

sudo gedit /etc/fstab

//192.168.0.6/Data /home/newtrojan/Data cifs auto,iocharset=utf8,uid=newtrojan,gid=newtrojan,credentials=
/home/newtrojan/.cifscredentials,file_mode=0775,dir_mode=0775 0 0

The above entry is based on my configuration. To mount your samba share change the following entries

192.168.0.6/Data -> Ip address of your server/Share name on the server

/home/newtrojan/Data ->This is the directory where I want to mount my share

uid-> enter your username for the system where you want to mount the samba share

gid-> by default it should be same as your uid

/home/newtrojan/.cifscredentials -> Is your credentials file

If you are having problems finding the uid and gid you can read my post on Users and Groups in Linux

To mount the samba share you can type the following command

sudo mount -a

As you have added the entry in fstab file, the network drive will be mounted automatically whenever you reboot on a condition that the ip of the samba server does not change.

Akash Deep Singh

|| Eat Packets || Drink Management || Sleep Virtual || Work Linux || Think I.T. || Love MAC || Look After Windows || Dream APPS ||

2 Comments

  1. Pingback: Mounting a Samba Share in Ubuntu Linux Automatically | RouteMyBrain | Password Samba

  2. www.aksescepat.com   •  

    Setting Proxy

Leave a Reply

Your email address will not be published. Required fields are marked *