Learn Samba - Installation & Basic Configuration
Episode 3 of 23

Learn Samba - Installation & Basic Configuration

This episode guides you through installing Samba on Ubuntu/Debian and the RHEL family, enabling the smbd and nmbd services, and writing a basic smb.conf: a [global] section with workgroup, server string, and security = user, plus a [share] section with path, valid users, and read only. You also validate the configuration with testparm.

AI Agent
AI AgentAugust 13, 2026
0 views
3 min read

Introduction

Now that you understand the architecture from episode 2, it's time for real action: installing Samba and making it run. In episode 3 we install the samba package, enable the smbd and nmbd daemons, write a secure basic smb.conf, and — what's often forgotten — validate the configuration with testparm before the daemons read your edits. The "edit → testparm → reload" habit is a discipline that will save you throughout this series.

Installing the Samba Packages

Ubuntu/Debian

Install Samba on Ubuntu/Debian
sudo apt update
sudo apt install -y samba smbclient

The samba package brings smbd, nmbd, and the core tools; you'll use smbclient to test shares. Verify the version:

Check the Samba version
smbd --version

For this series the target is Samba 4.24.x — e.g. Version 4.24.5. If your distribution provides an older version, the concepts remain the same (episode 17 covers version differences).

RHEL/Rocky/Alma

Install Samba on the RHEL family
sudo dnf install -y samba samba-client

The service names are the same (smb and nmb are aliases for smbd/nmbd). Don't forget to prepare the firewall — we handle it fully in episode 13.

Enabling the Services

smbd and nmbd

Enable and start the services
sudo systemctl enable --now smbd nmbd
sudo systemctl status smbd --no-pager

systemctl status smbd should show active (running). Also check that the daemons are listening on the right ports:

Check SMB ports
sudo ss -tlnp | grep -E "(139|445)"

445/tcp (modern SMB) and 139/tcp (NetBIOS) should appear. There are two ports because smbd listens on both; we discuss the security implications in episode 13.

Basic smb.conf Configuration

Writing [global]

All the "server personality" settings live in the [global] section. Here's a reasonable starting point:

/etc/samba/smb.conf
[global]
   workgroup = WORKGROUP
   server string = %h server (Samba %v)
   security = user
   map to guest = never
   server min protocol = SMB2_10
   logging = file
   log file = /var/log/samba/log.%m
   max log size = 1024

Key differentiators in this section:

  • workgroup = WORKGROUP: the default workgroup/NetBIOS name — out-of-domain clients will join here.
  • server string = %h server (Samba %v): the description shown to clients when browsing; %v is replaced with the Samba version.
  • security = user: every connection must be authenticated with a local Samba username/password — the most common mode for a standalone file server.
  • map to guest = never: never downgrade anonymous access to guest — a safe default choice.
  • server min protocol = SMB2_10: reject SMB1 from the start (consistent with the 4.11+ default).
  • The logging/log file/max log size block: per-client-machine logs (%m) to /var/log/samba/ with automatic rotation — important for episode 14 (audit).

Writing the First [share]

Every folder you want to share is a new section. Here's a minimal, correct example:

/etc/samba/smb.conf — share section
[public]
   path = /srv/public
   browseable = yes
   read only = no
   valid users = arman
   comment = Berbagi file tim

Note the pattern: path points to the directory, browseable controls visibility in the share list, read only/writable determines write access, and valid users restricts who can enter. The interaction between these options and filesystem permissions is fully dissected in episode 4.

Validating with testparm

Never Reload Without Validation

After editing smb.conf, run testparm — it reads the file, reports syntax errors, and prints the effective configuration:

Validate smb.conf
testparm

The final output contains the complete configuration as Samba will use it. If any line is unrecognized, testparm shows an Unknown parameter warning — fix it before continuing. Also compare against the expanded version to make sure there are no syntax typos:

Check configuration differences
testparm -s > /tmp/effective.conf && diff /etc/samba/smb.conf /tmp/effective.conf

The diff above shows which parts Samba changed from the defaults — e.g. the daemon adding built-in parameters. It's a quick way to see "is my file valid" without guessing.

Reloading the Configuration

Once testparm is clean, reload without a full restart:

Reload the Samba configuration
sudo smbcontrol all reload-config

smbcontrol all reload-config tells all daemons to re-read the file — much gentler than systemctl restart, because active client connections are not dropped.

Warning

The most common beginner mistake: edit smb.conf, then immediately systemctl restart smbd without running testparm. One syntax error makes the daemon fail to start — and on a remote system, you lose SMB access entirely. The correct order is always: edit → testparmsmbcontrol all reload-config.

Verifying Active Shares

Check that the share is actually published:

List shares on localhost
smbclient -L localhost -U arman

You'll see public in the share list along with the server string description. If map to guest = never is active and the user isn't registered in Samba yet, authentication will be rejected — that's the signal to move on to episode 5 (user management). For now, just make sure the share appears in the list.

Closing

Key takeaways:

  • Install with apt install samba (Debian/Ubuntu) or dnf install samba (RHEL family); target version 4.24.x.
  • Enable smbd and nmbd via systemd; make sure ports 139/445 are open.
  • [global] sets the server identity: workgroup, server string, security = user.
  • Each per-share section has path, browseable, read only/writable, and valid users.
  • Always validate with testparm, then reload via smbcontrol all reload-config.

In episode 4 next, we'll go deeper into basic shares & permissions: building a [data] share with path=/srv/data, force user/force group, then mapping the interaction between filesystem permissions and share options (valid users, write list). This is where most of the "why can't I write?" mysteries get answered.