Samba/CIFS shares in Ubuntu

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

This guide will walk you through configuring Samba/CIFS shares on your Ubuntu (12.04) server. If  all goes well, your Windows computers (as well as Macs) will be able to connect without issue. This guide has steps on how steps on how to set it up in the Desktop and in shell (ubuntu server). You do not need to do both.

Desktop (GUI)

Open the Ubuntu Software Center and search for “Samba”.
Install first the “SMB/CIFS file, print, and login server for Unix” then “Samba”.

Search for the Samba application in Dash Home, open it and when prompted, enter your admin password.

Go to Preferences > Server Settings and optionally set a description for your server here. Leave the Workgroup as “workgroup” unless your network uses something different.

We will need to add a unix user first before making a samba user. You can configure your shares by adding additional users that are allowed to connect to it. All you will need to do is add a standard unix user. In the terminal:

sudo adduser bob

Where bob is the name of the user you would like to create.  You will then be prompted to enter the password for the new user you created and optional values for full name, room number, work phone, etc. You can skip these by pressing Enter through each one. The primary user you created when you installed ubuntu will also work.

Back in the Samba Server configuration, go to Preferences > Samba Users.. and click Add User. Select the username you just created under Unix Username. Enter the same username under Windows username (or it can be different, it’s up to you) then enter and confirm the password for that Samba user. The password can also be different than the unix user. You can continue to populate the list of Samba users for your network.

Let’s add our shares. Click the green plus button or go to File > Add Share. Next to Directory, click Browse to go to the folder you want to share. Enter the name under Share Name and a small description right under it. Make sure you select “visible”. You can select Writable if you want the connected users to have write privileges to the share. Click the Access tab and check the boxes next to the names you want to allow. Optionally, you can select “Allow access to everyone”.

Repeat for all the shares you would like to add. Confirm it works by connecting to the server in Windows.

Terminal (Ubuntu Server)

The following are the steps for configuring Samba should you be running Ubuntu server or prefer not to use the GUI. In the terminal:

sudo apt-get install samba
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.original

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

First, we’re installing Samba then making a backup of the original configuration file. Let’s go ahead and configure Samba.

sudo nano /etc/samba/smb.conf

Generally, the defaults will work. You can always change specific settings in here. For instance, if your workgroup isn’t WORKGROUP by default, then you would specify that in this configuration file. Let’s uncomment one line by removing the semicolon in front of it.

security = user

At the very end of the document, add your custom shares.

comment = Storage
path = /mount/DiskB/
browseable = yes
read only = no
guest ok = no
create mask = 0644
directory mask = 0755
valid users = userName, bob, mark

Let’s go through this part bit-by-bit:

[Storage] – This is actually the name of the share. You can specify the name as you like. Don’t use more than 31 characters and avoid spaces if possible.
comment – Optional comment for the share.
path – The path to the folder you would like to share.
browseable –  Specifies that the share will be browseable by all clients.
read only – Pretty self explanatory
guest ok – Specify whether you allow guests to connect.
create mask – Default permissions for files
directory mask – Default permissions for directories
valid users – specify the users you would like to be able to connect, separated by comma and a space.

Let’s restart our Samba services.

sudo service smbd restart
sudo service nmbd restart

Finally, we’ll be configuring our Samba users. To add a user:

sudo smbpasswd -L -a userName

Then enter the password when prompted. To enable the user:

sudo smbpasswd -L -e userName

You’re set! Try to connect to your shares now.

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.