Part 4: Store files
16. Share folders with Mac and Windows#
What you'll do: make /srv/files appear as a network folder in Finder and File Explorer, with a password.
Time: 20 minutes. Uses Samba, the standard way Linux shares folders with Mac and Windows.
flowchart LR
M["Mac Finder<br/>smb://homeserver/files"] --> T(("Tailscale"))
W["Windows Explorer<br/>\\homeserver\files"] --> T
T --> S["Samba on server"] --> F["/srv/files"]
No hard drive yet?
Make a plain folder instead: sudo mkdir -p /srv/files && sudo chown alex:alex /srv/files. Move to a drive later (Chapter 15, then copy the files across).
Step 1: Install#
sudo apt install samba
Step 2: Set a file-sharing password#
Samba has its own password, separate from your login.
sudo smbpasswd -a alex
Type a new password twice and save it in your password manager. It should say Added user alex.
Step 3: Replace the settings with a simple, clean version#
The default settings also share your home folder and printers. Start fresh instead:
sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.original
sudo nano /etc/samba/smb.conf
Paste:
[global]
workgroup = WORKGROUP
server role = standalone server
map to guest = never
load printers = no
printing = bsd
printcap name = /dev/null
disable spoolss = yes
[files]
path = /srv/files
valid users = alex
read only = no
guest ok = no
Save, exit, and check for mistakes:
testparm -s
Look for Loaded services file OK. and a [files] section.
sudo systemctl restart smbd
systemctl is-active smbd
It should say active.
Step 4: Connect#
This uses the Tailscale name, so it works at home and away. Tailscale lets the connection through the firewall itself, so you don't need a new firewall rule.
- In Finder press Cmd+K (Go → Connect to Server).
- Type
smb://homeserver/filesand click Connect. - Choose Registered User: name
alex, password = the Samba password from step 2. - Tick "Remember this password in my keychain" if you like.
- Open File Explorer. In the address bar type
\\homeserver\filesand press Enter. - Username
alex, password = the Samba password. - To keep it: right-click This PC → Map network drive, folder
\\homeserver\files, tick Reconnect at sign-in.
Step 5: Test#
Drag a small file into the share. On the server:
ls -l /srv/files
The file should be listed.
Want it on the home network without Tailscale too?
Allow your home network (find it with ip route; it looks like 192.168.1.0/24):
sudo ufw allow from 192.168.1.0/24 to any port 445 proto tcp.
Then connect to smb://homeserver.local/files. Never open port 445 to "Anywhere" or on your router.
Done when: you can open, add and delete a test file from Finder or Explorer.
Next: 17. Automatic backups