Sunday, July 6, 2014

Accessing SMB (CIFS) Shares From Linux

A long-standard means of accessing shared files on a network has been through the use of Server Message Block protocol or SMB shares.  Now referred to as Common Internet File System or "CIFS", it provides a way for client workstations to share files with each other or access files from a central server. Security can be assigned at a share level to determine which individual or group of individuals may access the files.

Configuring CIFS shares is beyond the scope of this post, but you can learn more about setting up CIFS shares on both Linux and Windows by following the links below:

The Easy Way In Linux
Using Group Policy To Create Shares In Windows

Linux utilizes libraries developed through a project called "Samba".  You can find more information on Samba here.

Connecting to CIFS shares is vital for me at work. We store EVERYTHING on our server from customer documentation, downloaded utilities and applications, ISO images and even full computer images.  Without access to these important files, I might as well not bother coming to work at all!

Let's assume for now that I enjoy my job and therefore need a means to access these files from my Linux laptop.  Ubuntu makes it crazy-easy to do through it's native file browser. Opening the application, previously known as "Nautilus" but now simply labeled 'Files' (never would have guessed that, eh?), there is an option in the left panel for 'Network'.  This will populate the content pane with any CIFS servers it finds.

Clicking on any of the servers will provide a prompt to enter username, password and domain information.  (Following my previous post regarding joining a Linux machine to a Windows domain will allow the user to by-pass this step for domain servers!) You can also choose whether to remember those credentials for future connections or forget them right away.

Once connected, I find it best to create a 'Bookmark' to some common locations. These are the rough equivalent of mapped drives in Windows; a method to return to shared locations easily and uniformly.  To bookmark the location you've just accessed, Hit "Ctrl+D" or drop down the 'Bookmarks" menu and select "Bookmark this location".  The bookmark will then appear in the left pane making it very simple to go back to the share in the future.

There are many ways to access CIFS shares from Ubuntu and other Linux distros.  If you aren't using Ubuntu, you may need to install the 'cifs-utils' package from your distribution's repository.  Additional tools might be required as well such as 'samba-common'.

A more dangerous method of accessing CIFS shares is to "mount" them through fstab.  Although Ubuntu mounts the CIFS shares automagically when you access them through Files, in my opinion it does it more safely than having them mount at boot with fstab.  To learn more about mounting CIFS shares through fstab and command line, follow this link.

Hopefully this has been helpful to you and look for more posts in the future!