rss logo

Quick and Simple Samba Share Setup on Debian

samba linux logo

In this tutorial, I'll show you how to quickly set up a Samba server on Debian. The goal is to make the share quickly available from Windows, GNU/Linux or any SMB-compatible device. Personally, I often use it to create a temporary share when I need it.

Installing

  • Simply enter the following commands to install the samba package:
root@host:~# apt update && apt install samba

Configurations

We can now move on to configuration. First, we need to configure the IP address to which Samba clients will connect, followed by the Samba server configuration.

Network configuration

  • Edit the /etc/network/interface file, taking care to change the name of its network card according to its own configuration:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
# This is an autoconfigured IPv6 interface
allow-hotplug eth0
iface eth0 inet static
	address 192.168.1.200
	netmask 255.255.255.0
	gateway 192.168.1.254
  • Then restart the system to take the change into account:
root@host:~# reboot

Samba configuration

  • Create a share folder:
root@host:~# mkdir /share
  • Create a samba user:
root@host:~# adduser --home /share --system samba
  • Set permissions on the previously created folder:
root@host:~# chown samba: /share
  • Set a password (associated with the samba user) for access to the share:
root@host:~# smbpasswd -a samba
  • Clears the current config:
root@host:~# > /etc/samba/smb.conf
  • Then edit /etc/samba/smb.conf:
[global]
   workgroup = WORKGROUP
   server string = serv01
[share]
   path = /share
   read only = no
   valid users = samba
  • Check configuration:
root@host:~# testparm
  • And finally, restart your Samba services:
root@host:~# systemctl restart smbd; systemctl restart nmbd

Congratulations, sharing is ready! 🤝 The share will be accessible with the samba login and password previously defined with the smbpasswd command.