Samba implements the SMB protocol on Linux, enabling file sharing between Linux servers and Windows clients. This guide sets up a Samba file server on Ubuntu 24.04 LTS accessible from Windows and macOS machines.

Tested and valid on:

  • Ubuntu 24.04 LTS

Prerequisites

  • Ubuntu 24.04 LTS server
  • A user with sudo privileges
  • A Windows or macOS client on the same network

Step 1 – Install Samba

Install Samba and its dependencies:

sudo apt update
sudo apt install samba -y

Step 2 – Create the Shared Directory

Create a directory to share:

sudo mkdir -p /srv/samba/share
sudo chown -R nobody:nogroup /srv/samba/share
sudo chmod -R 0775 /srv/samba/share

Step 3 – Configure Samba

Back up and edit the Samba config:

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

Add a share definition at the bottom:

[myshare]
   comment = My Shared Folder
   path = /srv/samba/share
   browsable = yes
   read only = no
   guest ok = no
   valid users = sambauser

Step 4 – Create a Samba User

Create a Linux user and set a Samba password:

sudo adduser --no-create-home --shell /usr/sbin/nologin sambauser
sudo smbpasswd -a sambauser

Step 5 – Restart Samba

Apply the configuration:

sudo systemctl restart smbd nmbd
sudo systemctl enable smbd nmbd

Step 6 – Allow Samba Through the Firewall

Open the Samba ports:

sudo ufw allow Samba

Step 7 – Connect from Windows

On Windows, press Win+R and type:

\server_ipmyshare

Enter the Samba username and password when prompted.

Conclusion

Samba is now configured on Ubuntu 24.04 LTS. Windows and macOS machines can connect to the share using their native file managers without any additional software.