Simple Public Linux File Share Samba

Linux Logo

Simple Public Linux File Share Samba.

Create Samba User & Group

Create Samba Group

sudo groupadd --system smbgroup

Create Samba User

Create a system user that is unable to login.

sudo useradd --system --no-create-home --group smbgroup -s /bin/false smbuser

Root Folders

This will be where the share files live.
Choose an existing location or create a new folder.

sudo mkdir -p /share/public_files
sudo mkdir -p /share/protected_files

Adjust Folder Permissions

sudo chown -R smbuser:smbgroup /share
sudo chmod -R g+w /share #Gives the group write access

Install Samba

sudo apt install samba -y
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following additional packages will be installed:
attr libcephfs2 python-dnspython python-gpg python-ldb python-samba
python-tdb samba-common samba-common-bin samba-dsdb-modules
samba-vfs-modules tdb-tools
Suggested packages:
bind9 bind9utils ctdb ldb-tools ntp | chrony smbldap-tools ufw winbind
heimdal-clients
The following NEW packages will be installed:
attr libcephfs2 python-dnspython python-gpg python-ldb python-samba
python-tdb samba samba-common samba-common-bin samba-dsdb-modules
samba-vfs-modules tdb-tools
0 upgraded, 13 newly installed, 0 to remove and 91 not upgraded.
Need to get 5,149 kB of archives.
After this operation, 37.4 MB of additional disk space will be used.
Do you want to continue? [Y/n]

Stop Samba SMBD Service Daemon

sudo systemctl stop smbd

Edit /etc/samba/smb.conf

sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.sample
sudo nano /etc/samba/smb.conf

[global]
server string = File Server
workgroup = WORKGROUP
security = user
map to guest = Bad User
name resolve order = bcast host
include = /etc/samba/shares.conf

Edit /etc/samba/shares.conf


sudo nano /etc/samba/shares.conf
[Public Files]
path = /share/public_files
force user = smbuser
force group = smbgroup
create mask = 0664
force create mode = 0664
directory mask = 0775
force directory mode = 0775
public = yes
writable = yes
 
[Protected Files]
path = /share/protected_files
force user = smbuser
force group = smbgroup
create mask = 0664
force create mode = 0664
directory mask = 0775
force directory mode = 0775
public = yes
writable = no

Start Samba SMBD Service Daemon

sudo systemctl start smbd
sudo systemctl status smbd
  • https://www.samba.org/samba/what_is_samba.html