Install Samba file server for WindowsInstall Samba file server for Windows KCTang Tue, 07/05/2019 - 20:16
28 Jul 2022: Correct the positions of two statements. "gedit" changed to "nano" in case non gui interface is used.
7 May 2019: Slight adjustments. "gksudo gedit" changed to "sudo gedit" as Ubuntu 18.04 dropped "gksudo".
25 Dec 2014: First created.
Samba file server enables specified directories to be accessible by Windows computers on the same network.
Install the package:
$ sudo apt-get update $ sudo apt-get install samba
Define a workgroup
Edit the config file:
$ sudo nano /etc/samba/smb.conf
Define workgroup name as "kctcl" in the "[global]" section:
workgroup = kctcl
Uncomment to restrict access to server users only:
security = user
Add the following if OpenVPN used:
hosts allow = 192.168.0. 10.8.0. 127.0.0.
(added 7 May 2019):
Put the last two statements under the "[global]" section after "Networking" instead of at the end, otherwise "security = user" will apply to the last shared directory causing it to be non-assessible.
(added 28 July 2022)
Define directories to be shared
Add a section at the end to share directories:
[<sub-directory name or other short name>] pth = /<directory name>/<sub-directory name> browseable = yes guest ok = yes read only = no create mask = 0775 directory mask = 0775 # do not include the next two lines if access is restricted to the owning user (added 7 May 2019) force user = nobody force group = nogroup
Create the directory to be shared, if not already existing:
$ sudo mkdir -p /<directory name>/<sub-directory name>
Change ownership of the directory:
$ sudo chown nobody:nogroup /<directory name>/<sub-directory name>
Start or restart Samba service whenever the config file is changed:
$ sudo systemctl restart smbd nmbd
or, if ".service" is not automatically appended when executing the above command:
$ sudo systemctl restart smbd.service nmbd.service