Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Install and Configure Samba on Ubuntu

Share a folder from Ubuntu with Windows and other computers using Samba.

VPS and Cloud Servers2 min read10 screenshots

What Samba does

Samba lets Linux share files and printers with Windows (SMB/CIFS). Features:

  • File and printer sharing.
  • Authentication and access control.
  • Network browsing.
  • Domain controller support.
  • Support for many file systems.
  • Data encryption.
  • Command-line tools.

Install Samba

Step 1: Update

sudo apt update
Updating the repositories

Step 2: Install the packages

sudo apt install samba samba-common
Installing Samba
  • samba has the main Samba server programs (smbd, nmbd).
  • samba-common has common files and tools.

Step 3: Check it

smbd --version
The Samba version

Configure Samba

Step 1: Create a shared folder

mkdir /home/username/sambashare/
Creating the shared folder

Step 2: Edit the Samba configuration

sudo nano /etc/samba/smb.conf
Opening smb.conf

Add this at the end of the file:

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

Step 3: Restart Samba

sudo service smbd restart
Restarting the Samba service

Step 4: Open the firewall

sudo ufw allow samba
Allowing Samba

Step 5: Set the permissions

sudo chown -R username:sambashare /home/username/sambashare/
Setting the folder owner

If the group sambashare does not exist, make it first with sudo groupadd sambashare, or use your own group.

Step 6: Create a Samba user

The user must exist on the system. Add a Samba password for it:

sudo smbpasswd -a username
Creating the Samba user

Step 7: Check the configuration

testparm
Checking the configuration with testparm

Connect from Windows

Open File Explorer and type in the address bar:

\\server_ip\sambashare

Enter the Samba user name and password.

Connect from Linux

sudo apt install cifs-utils
sudo mount -t cifs //server_ip/sambashare /mnt -o username=username

Why people use Samba

  • It bridges Linux and Windows.
  • It is open source and free.
  • It has a big community and is very customizable.
  • It is reliable, and it fits into existing networks.

Quick recap

  • Install samba, create a folder and add a share to smb.conf.
  • Add a Samba user with smbpasswd -a.
  • Open the firewall and connect with \\server_ip\sambashare.