Install and Configure Samba on Ubuntu 18.04 LTS

What is Samba ?

It is file sharing server that enables file sharing among different operating systems over LAN(Local Area Network). It gives you interface to share files from desktop to MAC and other operating systems. In this article, you will learn how to install and configure SAMBA on ubuntu.

What you will learn ?

  • How to install and configure samba on Ubuntu
  • How to share file across LAN(Local Area Network)

Requirements

  • Ubuntu 18.04 or Any
  • Local Area Network(LAN) to share files

If you meet all these requirements then lets get started.

Installation

To install samba on your local machine you have to download it locally (installation process is same if you are installing on remote server) to install we run:

sudo apt update
sudo apt install samba

Run the below command to checking if the installation was successful.

whereis samba

The following command will output like this.

samba: /usr/sbin/samba /usr/lib/samba /etc/samba /usr/share/samba /usr/share/man/man7/samba.7.gz /usr/share/man/man8/samba.8.gz

Configuration of Samba

Samba is install completely now we have to create a directory which we will share.

mkdir /home/<username>/sambashare/

To run this command change username to your actual username. This command will create a directory named sambashare.

After that you have to edit the configuration file which is location at /etc/samba/smb.conf 

sudo nano /etc/samba/smb.conf

At the bottom add the following lines

[sambashare]
    comment = Samba on Ubuntu
    path = /home/username/sambashare
    read only = no
    browsable = yes

Then press Ctrl-O to save and Ctrl-X to exit from the nano text editor.

What we added in Config

  • [sambashare]: The name inside the brackets is the name of our share.
  • comment: A brief description of the share.
  • path: The directory of our share.
  • read only: Permission to modify the contents of the share folder is only granted when the value of this directive is no.
  • browsable: When set to yes, file managers such as Ubuntu’s default file manager will list this share under “Network” (it could also appear as browseable).

Now that we have our new share configured, save it and restart Samba for it to take effect:

sudo service smbd restart

Setting up User Accounts and Connecting to Share

Samba does not use system user accounts so we have to create samba accounts to share files with others. To create user run the following command.

sudo smbpasswd -a username
Note:

Username used must belong to a system account, else it won’t save.

Connecting to Share

On Ubuntu:
Open up the default file manager and click Connect to Server then enter:

Run Samba on Ubuntu

On macOS:
In the Finder menu, click Go > Connect to Server then enter:

Run Samba on macOS

On Windows, open up File Manager and edit the file path to:

\\ip-address\sambashare

You’ll be prompted for your credentials. Enter them to connect!

Install Kali Linux on Virtual Machine (VM Ware)