How to Install and Configure Samba on Ubuntu

If you have a network that comprises of both Windows and Linux machines and you want to enable sharing between them. You can achieve this by using a useful tool Samba. It is an open-source tool that allows you to access shared resources including files, printers, etc.

In this article, we will show you how to install and configure Samba as a file storage system for Windows and Linux OS. We will also show you how to access Samba shared files using other Linux and Windows client OS. Before accessing the shares, make sure you have the server and client OS in the same IP subnet.

For this article, I am using Ubuntu 18.04 LTS for the installation and configuration of Samba server.

Installation of Samba on Ubuntu

Launch the Terminal by pressing Ctrl+Alt+T key combinations then enter the following command to install Samba.

$ sudo apt install samba

Install Samba with apt

Verify SAMBA installation

You can verify if the Samba has successfully installed and running by entering the following command. It will show the status of the Samba service.

$ sudo systemctl status nmbd

Check the status of nmbd service

You can see the above status that the Samba is active and running.

Configuration of Samba

Once you have down with the installation, you will need to configure it.

1. First, we will need to create a Samba directory, where all the shared data will be stored. Open the Terminal and run the following command as sudo:

$sudo mkdir /samba

Create a new directory for Samba

It will create new subdirectory samba in the root directory.

2. Make a backup of the configuration file by copying it in the same or another directory. To copy the file, run the following command as sudo:

$ sudo cp /etc/samba/smb.conf /etc/samba/smb_backup.conf

It will make the backup file in the same directory.

3. Now edit the configuration file.The configuration file of Samba is located in /etc/samba/ in a file named smb.conf. You can use Gedit, Nano or Vim to edit any config file. To edit the file using nano editor, open Terminal and run the following command as sudo:

$ sudo nano /etc/samba/smb.conf

Edit Samba configuration

Configuring Samba Shares

Now we will configure our new directory samba as a share. For this, we will have to add the following lines in the Samba configuration file.

Add the following line to the bottom of the smb.conf file.

comment = Samba on Ubuntu
path = /samba
read only = no
browsable = yes


  • [samba-share] = name of the share
  • comment= Add a brief description of the share
  • Path= It is the directory of your share.
  • Read only = It specifies whether or not a user is allowed to write
  • Browsable = whether the share should be listed in the share list

Add Samba share

Press Ctrl+O to save and Ctrl+X to exit.

Setting up Samba User Account

Now, set up a user account for Samba. Samba use system account for accessing the share but it does not accept the system account password. so we will need to set up a password for that account by entering the following command as sudo. When requested for the password, Type new password.

$ sudo smbpasswd -a username

Restart Samba Service

Once you have down with all the configurations, restart the Samba service by running the following command:

$ sudo systemctl restart smbd.service

Connecting Samba Share

As previously discussed, you should be in a LAN to access files from the Samba server. That means the IP of your Samba server and the clients who are connecting to it should be in the same network.

For instance, in my scenario, I have one Samba server and two clients: one is Linux and the other is Windows. All three machines are in the same network.

  • IP of Samba (Server):
  • IP of Linux (Client):
  • IP of Windows (Client):

Samba server IP configuration

You can check the IP address of any machine by running ifconfig in Terminal.

$ ifconfig

Following is the IP configuration of my Samba server:

Network configuration

Method 1: Connecting from Linux

There are two ways through which you can connect Samba share from Linux client.

1. Using Command Line

2. Using GUI

Following is the IP configuration of my Linux client is:

IP address

1. Using the command line

To connect Samba share through the Linux command line, you will need a smbclient tool. To install smbclient, open the Terminal run the following command as sudo:

$ sudo apt install smbclient

Install smbclient

Once the installation is completed, run the command by using the following syntax to access Samba share.

$ sudo smbclient //[IP_address or Host_name]/share_name –U username
  • [IP_address or Host_name] is the IP address or the host name of the Samba server
  • [share_name] is the name of the Samba share
  • [username] is the name of the user that is accessing the share

It will prompt for the password. After you enter the password, you will be logged in to Samba CLI. You can type help to see a list of various commands.

Connect to Samba using smbclient command

2. Using GUI

To access Samba share via GUI, open Linux File Manager. Click on Connect to Server on the left pane of the File Manager window.

Connect to Samby using GUI

In a Connect to Server window, enter the Samba server address in the following syntax and click Connect.

smb:// [IP_address or Host_name]/[share_name]

Connect to Samba Share

The following screen will appear. From Connect As option, select Registered User.

Enter Samba username and password. Leave the Domain as default and click Connect.

Enter details

You will see the connection has established. Now you can access the files on Samba server.

Samba share on Linux

Method 2: Connecting From Windows

You can connect to Samba share using Windows OS in two ways:

1. Using Run utility

2. Using File Explorer

Following is the IP configuration of My Windows client machine:

Connect to Samba from Windows

1. Using Run utility

Press Windows key + R to launch the Run utility. Enter the address in the following syntax to access Samba share and press Enter.


Use the Run utility

It will be prompted for credentials. Enter credentials for Samba share, then click OK.

Enter network details

You will see the connection has established. Now you can access the files on Samba server.

Samba share visible in Windows

2. Using File Explorer

Launch File Explorer in Window. In the left pane, right click on This PC. Then select Add a network location from drop-down options.

Using File Explorer

It will launch the Add Network Location wizard. Keep clicking on Next until the following screen appears. Add Samba share address in following the syntax and click Next.


Add network location

In the next screen, you can change the name of the shared location. Click Next and then click Finish to complete the process.

When the above process is completed, it will prompt for credentials, enter the credentials for Samba share and click OK.

Enter Network Credentials

You will see the connection has established. Now you can access the files on Samba server.

Samba share connected successfully

Therefore, to wrap things up, we have learned how to install and configure Samba on Ubuntu 18.04 LTS to create shares. We have learned how to connect those shares using Linux and Windows OS.