Ubuntu Tips: 4 - Install Samba File Server

Here you can find a tutorial explain how to install and configure a Samba File Server on an Ubuntu Linux computer

Author: Matthew Wittering | Published: 26th October 2009

If you want to share files between your Ubuntu and Windows machines you should install Samba. Samba allows a non-Windows computer to masquerade itself as a Windows File Server. Doing so allows greater interoperability on heterogeneous computer networks to share files. Whether your machine is running Apple Macintosh, UNIX, Linux, IBM OS/2, or Novell Netware; Samba allows you to share your files with Microsoft Windows computers.

Installing the software and configuring Ubuntu as a Samba File Server is a rather simple exercise. The aptitude package manager will cover most of the hard work but you will need to modify the configuration file to complete the exercise.

Step 1 - Installation

Start by opening a new Terminal window or login via SSH to the Ubuntu system you wish to modify. Then run the following command:

sudo apt-get install samba smbfs

Step 2 - Configuration

Once the installation is complete and the Samba Daemon is running we can move on to configuring the system. The command below will open the configuration file with the nano text editor. Please substitute nano it for your preferred editor:

sudo nano /etc/samba/smb.conf

Now that you have successfully located and opened the configuration file find the Authentication section. Alter the following line and include the second line below.

Before:

# security = user

After:

security = user
username map = /etc/samba/smbusers

Next find the Share Definitions section and modify the configuration file so it reads as below:

# Un-comment the following (and tweak the other settings below to suit)
# to enable the default home directory shares.  This will share each
# user's home directory as \\server\username
[homes]
comment = Home Directories
browseable = yes

# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
read only = no

Once you have made the alterations, save the file and close your editor.

Step 3 - User authentication

All that remains is to create the matching Samba username to the System username. This can be done with the following commands. Replace 'matthew' with the username you wish to use when accessing the system. Then type a memorable password.

sudo smbpasswd -a matthew

Now that stage is complete we must finish associating the Samba username and password to the users home directory. Open the following file in an editor of your choice:

sudo nano /etc/samba/smbusers

As before replace 'matthew' for the username you are supplying for your system:

matthew = “matthew”

Now save and close the smbusers file and restart the Samba Daemon and you will then be ready to use your Ubuntu computer as a Samba File Server for your data across the network.

sudo service samba restart

Step 4 - Accessing the file server

To access your Ubuntu server from another machine you should enter the server name and username formatted with the appropriate pattern for your system. Once you have entered the address and started the connection process when asked you must supply the username and password for the desired account. After you have been successfully logged in, browse the network share like you would a local storage device.

Microsoft Windows:

//servername/username

All other computer systems:

smb://servername/username

This work is licenced under a Creative Commons Licence

A brief introduction

Matthew WitteringI am a graduate of Lougborough University where I read Computing and Management BSc (Hons) earning a 2:1 classification.

Currently I am working in the Product Team as a Junior Product Manager at Ask Jeeves UK. Continue