What is a Samba server?

A Samba server refers to a server that is supported by the free software suite, Samba. With the help of Linux and Unix dis­tri­b­u­tions, the GNU licensed package is able to implement SMB protocols (the suite’s namesake). The server message block (SMB) protocol, also known as common internet file system (CIFS), was orig­i­nal­ly used for file, printing, and other services for Microsoft Windows operating systems. Samba servers support Windows, Linux, and Unix in­te­gra­tion systems, making it possible to share files or use printers on any operating system. Since the launch of version 4, Unix and Linux Samba servers have taken over the role of Active Directory domain con­trollers, which allow central au­tho­riza­tion and au­then­ti­ca­tion for both computers and users.
Samba servers are made up of several modules, allowing SMB or CIFS protocols to be con­fig­ured. The following four daemons (systems that run in the back­ground) are at the core of the Samba server:

  • samba: this daemon was added in version 4 and enables the Active Directory domain con­trollers. It is con­fig­ured in the file smb.conf.
  • smbd: this enables file and printer sharing and is con­fig­ured with smb.conf.
  • mbd: this is re­spon­si­ble for ter­mi­nat­ing NetBIOS names in IP addresses and can also be con­fig­ured with smb.conf.
  • winbindd: winbindd resolves group and user in­for­ma­tion, making it in­tel­li­gi­ble for Unix and Linux systems. It offers stand-alone con­fig­u­ra­tion options.

How to install a Samba server

SMB/CIFS is the standard protocol for un­com­pli­cat­ed network sharing on Windows systems. However, when computers with Linux or Unix operating systems belong to the network, ex­chang­ing and sharing files becomes a more difficult task. By in­stalling a Samba server, which connects in­di­vid­ual devices, these com­pat­i­bil­i­ty problems are solved. Since the Samba package consists of open source com­po­nents, there are no ad­di­tion­al costs. The following steps outline how to install a Linux Samba server.

Step 1: in­stal­la­tion

First, decide whether to operate directly on your server or from a client via remote access. Then enter the following command in order to install the Samba package onto the server:

apt-get install samba

Step 2: create a user account for the Samba database

After in­stalling the Samba server, the user account must be activated. Some Linux dis­tri­b­u­tions au­to­mat­i­cal­ly syn­chro­nize the user accounts in the network and add the Samba database. If the package libpam-smbpass is already installed on the server, the Linux and SMB passwords will be syn­chro­nized. Otherwise, all accounts have to be created manually for the users to be able to access the re­spec­tive network services. 

The account can be set up using the command smbpasswd with the four pa­ra­me­ters -a, -x, -d and -e. The cor­re­spond­ing command lines will appear as follows:

sudo smbpasswd -a USERNAME (PASSWORD)
sudo smbpasswd -x USERNAME
sudo smbpasswd -d USERNAME
sudo smbpasswd -e USERNAME

The first command adds the user to the Samba server database and enables network sharing. Directly following the username, the user may covertly set or change a password. It can be identical or differ to the Linux password. The second command (-x) removes the user from the database, the -d parameter de­ac­ti­vates the account, and -e re­ac­ti­vates it. The command

sudo service smbd reload

reloads the server con­fig­u­ra­tion in order to accept new changes.

Step 3: configure file sharing

Global settings

Global settings can be set in the Samba server con­fig­u­ra­tion file. The resource per­mis­sions and the server’s global prop­er­ties are saved here. The file is opened with the following command:

sudo gedit /etc/samba/smb.conf

The file smb.conf contains many examples that are commented out, which are iden­ti­fied either by a hash (#) or semicolon (;) and are inactive. Should you wish to activate one of these examples, simply delete the ad­di­tion­al character. New entries can be inserted at the end of the file. Firstly, specify the global name in square brackets under which the shared resource is available. The next lines describe the path to the re­spec­tive folder or file as well as the ap­plic­a­ble pa­ra­me­ters. For example, to share a folder with photos, allowing the user writing access as well as guest user access, the entry in the smb.conf is needed:

[Photos]
path= /documents/photos
writeable = yes
guest ok = yes

To accept the changes, reload Samba by executing the following command:

sudo service smbd reload

User sharing

In order to set up user-specific resource sharing, the user needs to belong to the group sam­bashare. The following command adds the user to this group:

sudo usermod -aG sambashare USERNAME

Login again or restart Linux to confirm group mem­ber­ship. If the user is setting up clear­ances, these will no longer be saved in the smb.conf; rather, they will now be found in a separate text file, usually /var/lib/samba/user­shares. All of these files include the share name and approval path, an optional comment, the user share ACL (which indicates whether the shared folder can be edited or whether it is read-only) as well as a parameter that shows who has access to the file. For example:  

net usershare add Photos /documents/photos ‘holiday 2015’ Everyone: r, USER1: f

This command allows the folder with the sharename ‘Photos’ in the path ‘/documents/photos’ and the comment ‘holiday 2015’ to be shared. All Samba server user accounts can read the folder. USER1 has the full rights and can change the settings. The following command can be used to check the folder:

net usershare list
net usershare info

The first command lists all the shared folders under the re­spec­tive sharename, while the second gives details like comments, rights, etc. If the user wishes to make changes to the folder, the values should always be entered on the command line, rather than in the user­shares text file. Approvals can be deleted with the command:

net usershare delete SHARENAME

Samba server: Windows and Linux united in one network

With the joint use of printers and files in one network, a Samba server and Samba client software provides an elegant solution to problems caused by different operating systems. The free software suite im­ple­ments the network protocol SMB/CIFS in Unix and Linux systems and by doing so makes them com­pat­i­ble with Windows dis­tri­b­u­tions in the network – both servers and clients.

Due in part to its new role as Active Directory Domain Con­troller, a Linux Samba server manages the sharing of data and services in networks such as Windows servers. Those who want to install a Samba server can easily do so from their personal computer via remote access. Users also have the choice of working directly on the command line or in­stalling a graphic interface for sim­plic­i­ty’s sake

Go to Main Menu