Samba is a Linux/UNIX software package that allows you to share files and directories with computers running other operating systems over the network. It also allows your Linux desktop or laptop to sign into a Windows network and be able to share files inside a workgroup. There are several advanced features that Samba comes with, such as domain controller. We will look at how to convert your Ubuntu box into a Samba file server and configure it to share directories with different combinations of permissions.
When setting up a Linux file server, there are certain things that you will to have set up on your server before you start working on the Samba bit. The first thing you want to do is to set up the server with a static IP address, as opposed to one assigned dynamically by a DHCP server. Edit the file ‘/etc/network/interfaces’ with root user privileges and set the IP address manually. An example of the settings would be using something like the following:
[sourcecode language=”bash”]auto eth1
iface eth1 inet static
Using a static IP for any type of server makes good sense. Save the changes and restart the network with the command ‘# sudo /etc/init.d/networking restart’.
02 Installing Samba
Distributions such as Ubuntu have made the installation of just about anything so simple and straightforward with smart package management that you can have pretty much any software installed with a one-line command. To install Samba on your Ubuntu computer, execute the following:
[sourcecode language=”bash”]# sudo apt-get update
# sudo apt-get install libcupsys2 samba samba-common[/sourcecode]
Here we are requesting Ubuntu to install three packages. The first one is to share your printer, the other two are Samba and its support packages.
03 Configuration file
The configuration files of Samba are stored in the ‘/etc/samba/’ directory. The first thing you should do before we dive into the configuration of Samba is to make a backup of the main configuration file.
[sourcecode language=”bash”]# cp /etc/samba/smb.conf /etc/samba/smb.conf.bak[/sourcecode]
Now open the file with your favourite text editor and let’s make some configuration changes:
[sourcecode language=”bash”]# sudo vim /etc/samba/smb.conf[/sourcecode]