Ubuntu 18.04 – Install Samba Server

What is Samba?

Samba is the standard Windows interoperability suite of programs for Linux and Unix. ~ https://www.samba.org/

Microsoft’s Windows operating system (OS) has historically been the most popular and widely installed operating system in the world. However, it is not the only operating system and others are gaining more market share every year.

As a developer, I lean on the flexibility of Ubuntu Linux. I have found it easier to install, remove, and update many pieces of software on Ubuntu than on the Windows OS. The Ubuntu community is very large, active, and helpful when it comes to understanding and troubleshooting Ubuntu versions. There are also many other Linux distributions and users worldwide.

Google’s Android OS has also taken large market shares in recent years. Mobile devices have changed the way that websites are developed. Mobile devices have the capability to create pictures, videos, and even conventional data like text documents and spread sheets.

Samba Provides File and Print Services

If you own several devices and use them on a home network, for example, you may find the need to share files between them. A mobile user may connect their phone to a computer via a usb connection to transfer files to a desktop or laptop; however, a Samba server would allow the devices to share files right over a shared network. A mobile user could, in practice, join a virtual private network, and then manage files from their device to a shared hard drive, or even print a file right from their laptop or phone.

Installing Samba on Ubuntu 18.04

It is always a good idea to update and upgrade any packages that may need updating before installing new software. To begin Samba installation on Ubuntu 18.04 open a terminal shell and enter:

sudo apt update
sudo apt upgrade

After updating and upgrading the Ubuntu system, it is time to install Samba.

sudo apt install samba

According to the Ubuntu package archive, there are various other required programs that will be installed alongside Samba such as samba-common.

If you have the UFW firewall enabled, you’ll want to be sure to allow Samba traffic in using the following commands:

sudo ufw allow in Samba
sudo ufw reload

This will allow Samba through the firewall when other machines try to use the service.

At this point, Samba is installed. To check the status of the service, enter the command:

sudo systemctl status smbd

You’ll see a screen that reads something like:

 Loaded: loaded (/lib/systemd/system/smbd.service; enabled; vendor preset: ena
Active: active (running) since Sun 2018-06-24 18:49:20 UTC; 3min ago

If the status doesn’t read active, you may have had some sort of error during installation.

The Samba Configuration File

After Samba has been installed, it needs to be properly configured. Samba has a configuration file that can be altered to set configuration parameters. On Ubuntu 18.04, the file is at

/etc/samba/smb.conf

It is a good idea to backup the configuration file for later references. To do so use the following command to make a copy a file called smb.conf.bak.

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

There are many ways to configure Samba, but this article will only configure a public share folder that can be accessed by any user on the network. Open the configuration file with a text editor as in the next command:

sudo nano /etc/samba/smb.conf

You’ll want to go to the very bottom of the configuration file and place the following configurations.

[Public]
comment = Public Samba Share Directory
path = /var/samba
browseable = yes
writeable = yes
guest ok = yes
guest only = yes

This creates a share block called “Public”, sets the directory at /var/samba and adds a few more configurations that allow the directory to be browseable, writeable, and accessible to anonymous users that do not need to log in. After this is entered into the configuration file, save and close the file.

At this point, the actual directory of /var/samba has not yet been created. You can change the path location to wherever you’d like, however, this is the command to create the directory at the path that I have configured:

sudo mkdir /var/samba

Because this directory is being established as a public directory accessible to whoever has access to it, I will also change the folder permissions.

sudo chmod 777 /var/samba

Now that Samba has been configured and the public samba directory has been created, the samba service should be restarted.

sudo systemctl restart smbd

Connecting to Samba

After Samba has been configured for a Public directory, you can search for the drive on any other computer that is connected to the network. On Windows or Linux, you’ll open the File Explorer and click on the “Network”, or “Other Locations” directory. When there, you’ll find the name of the system that has Samba installed. You should now be able to access a folder within this directory named “Public”. This is your public shared directory.

Leave a Reply

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