May 5, 2025•5 min read••
Tags ▼
No tags
With Samba, you can easily set up shared network storage that is accessible by all devices in your home, including Windows, macOS, and Linux systems. Samba is an open-source implementation of the SMB/CIFS protocol, the same protocol used by Windows file sharing. This means your server can act as a file server, providing a shared drive for your home network.
Here’s a detailed guide on how to configure Samba for your home server.
Samba is included in the Ubuntu repositories, making installation simple.
SSH into your server and run:
sudo apt update sudo apt install samba
After installation, check the Samba version to ensure it’s installed correctly:
sudo smbstatus
If Samba is installed, this command will display the current status.
Choose a location for your shared files. For example:
sudo mkdir -p /media/myfiles
Change the ownership and permissions of the directory to make it accessible:
sudo chown $USER: /media/myfiles sudo chmod 775 /media/myfiles
chown: Makes the current user the owner of the directory.chmod 775: Ensures the owner has read, write, and execute permissions.Open the Samba configuration file with a text editor:
sudo nano /etc/samba/smb.conf
Find the line:
map to guest = bad user
Change it to:
map to guest = never
This ensures users are required to authenticate with valid credentials.
Add a new shared folder configuration at the end of the file:
[MyFiles]
path = /media/myfiles
browseable = yes
writable = yes
valid users = [your-username]
read only = no
create mask = 0755
path: The directory you created for shared storage.browseable: Makes the share visible to network users.valid users: List the usernames that can access the share.create mask: Ensures files are created with the correct permissions.Save the file by pressing Ctrl + X, then Y, and Enter.
To access the shared folder, you need a Samba user with a password.
You’ll be prompted to enter and confirm the password.sudo smbpasswd -a $USER
To apply the changes, restart Samba:
sudo systemctl restart smbd
\\[server-ip]\MyFiles
smb://[server-ip]/MyFiles
smb://[server-ip]/MyFiles
To automatically mount the shared folder on Linux clients:
Open the terminal and edit the fstab file:
sudo nano /etc/fstab
Add the following line at the end:
//server-ip/MyFiles /mnt/myfiles cifs username=[your-username],password=[your-password],iocharset=utf8,vers=3.0 0 0
Create the mount point:
sudo mkdir -p /mnt/myfiles
Mount the shared folder:
sudo mount -a
This ensures the shared folder is mounted every time the computer reboots.
Connection errors? Make sure the firewall on your server allows Samba traffic:
sudo ufw allow samba
Check the Samba service status:
sudo systemctl status smbd
Verify the shared folder:
testparm
This checks the Samba configuration for syntax errors.
Permissions issues? Ensure your shared folder permissions are correct:
sudo chmod -R 775 /media/myfiles
With Samba, your $0 Home Server becomes a centralized file server for your entire network. It works seamlessly across Windows, macOS, and Linux devices, allowing you to store, access, and back up files easily. This setup is perfect for network storage, media hosting, and collaborative file sharing without needing expensive NAS devices or cloud subscriptions.
By following these steps, you now have a fully functional network drive that can be accessed by all devices in your home.
Follow on your preferred channel for new articles, notes, and experiments.