About technologies for your digital home

For beginners and tinkerers

Ubuntu Samba

April 10th, 2014

What is Ubuntu Samba?

Samba (SMB) is the standard Windows file and printer sharing SMB/CIFS protocol, which was implemented for Linux and Unix machines to communicate with Windows-based.

If you use a mixed Windows & other operating systems environment, Samba can be quite useful protocol, to upload/download the files inside your home network plus for accessing the printers.

It is worth to mention, that Samba is not enough secure protocol. So it should not be exposed directly to the Internet e.g. using the port forwarding on your router etc.

Install Ubuntu Samba on your server

For the start, just connect to your Ubuntu server using SSH.

At the begging, you will have to update the repository package list & locations:

sudo apt-get update

After this, you will have to install Ubuntu Samba service itself by issuing the commands:

sudo apt-get install samba samba-common

Configure Ubuntu Samba

The next step is to create Samba share on your server.

That can be done by editing the Samba configuration file:

sudo nano /etc/samba/smb.conf

There is ‘Global Settings’ section, where you should see the variables ‘workgroup’ and ‘security’ (which is commented by default). They need to be adjusted to your needs and your network:

   workgroup = YOUR_WORKGROUP_NAME
   security = USERNAME

You should add a new section at the end of the file for the directory to be shared.

The variables ‘comment’ and ‘path’ need to be modified according to your needs:

    comment = Home Ubuntu Media Server Share
    path = /home/user/Videos
    browsable = yes
    guest ok = yes
    read only = no
    create mask = 0755

Brief explanation of the variables:

  • comment: a description of your share
  • path: the directory (including the path) to share
  • browsable: the shared directory can browsed by Windows clients using Windows Explorer
  • guest ok: clients do not need to be authenticated by providing a password
  • read only: set the permissions on the share to read only access

If you chosen path does not exist, you may create it using the comands:

sudo mkdir -p /home/user/Videos

Setting the permissions

As you could see previously, some Samba protocol permissions were setup in smb.conf file (create mask = 0755)

The Linux permissions for this share should be setup as well:

sudo chown nobody.nogroup /home/user/Videos

That will allow everyone who have an access to your network to read/write/modify/delete the files or folders on this share.

At the end, you have just to restart Ubuntu Samba service:

sudo restart smbd
sudo restart nmbd

You can find more details on configuring Ubuntu Samba server on official Ubuntu documentation.