Tired of juggling external drives and dealing with the limits of cloud storage? Create a simple Linux server and Samba in about 30 minutes and use your own personal network storage, accessible from virtually any home device, without worrying about connection speeds or extra hardware.
I have a minimalist approach to storing files on my local machines. I like to keep things organized and ensure I have plenty of free space—a habit from the days when disk space was measured in megabytes.
Attached storage works well, but it’s still local unless you take it with you, and I’ve lost count of the times I’ve left a thumb drive in another device. Cloud storage is a good alternative, but connection speed and file size can be limiting, especially when dealing with large files.
Ever since I started building Linux servers, Samba has been my go-to for sharing files across my home network. It’s perfect for tucking away files for safe-keeping and archiving things I may never need again—but I like to keep just in case.
I use a headless Ubuntu server to stream media, share a printer, store large files, and back up important data. I manage it from anywhere via SSH, which works fine for system updates, adding users, and general admin tasks. For bigger file operations—like organizing or moving things around—the command line can get tedious, so I use network shares to manage files and folders from my Mac or Windows desktop,
We'll install Samba via the command line on Ubuntu, Fedora, and Arch Linux. Once installed, configuring Samba is the same no matter the Linux distro.
Open your favorite terminal emulator to install the Samba package.
sudo apt updatesudo apt install samba
Optionally, if you have a firewall running on your server, you might need to allow Samba through it.
sudo ufw allow sambaFinally, start and enable the Samba services.
sudo systemctl start smbdsudo systemctl enable smbd
Install the Samba package.
sudo dnf install samba samba-clientOptionally, configure the firewall.
sudo firewall-cmd --permanent --add-service=sambasudo firewall-cmd --reload
Start and enable the Samba services.
sudo systemctl start smbsudo systemctl enable smb
Install the Samba packages.
sudo pacman -S sambaStart and enable the Samba services.
sudo systemctl start smbsudo systemctl enable smb
If using firewalld, allow Samba through the firewall.
sudo firewall-cmd --permanent --add-service=sambasudo firewall-cmd --reload
If using ufw:
sudo ufw allow SambaBelieve it or not, that's probably the hardest part. Samba is now running on your system. You can enter sudo systemctl status smbd to check that the server is running.
Even though Samba is up and running, you still need to configure it, so your file server is visible on your local network, then set up a simple share.
You do all this in the smb.conf file, which is almost always located at /etc/samba/smb.conf.
Using your favorite text editor, enter sudo vim /etc/samba/smb.conf to open the Samba configuration file.
Now you can create a very basic Samba configuration based on the following:
[global]The global section of the smb.conf file defines the overall configuration settings for the Samba server. These settings apply to all shares and control how the server interacts with clients on the network.
The only parameters you will want to change are the workgroup and NetBIOS name. The workgroup parameter simplifies the process and enhances network discovery and interaction. If computers are in different workgroups, you can still share files, but additional configuration steps may be necessary to facilitate access and communication between devices. The NetBIOS name allows you to see and connect to the server with that name, instead of the ip address.
To show you how this all works, we now need to set up one simple share using your user's home directory. Add this section to the smb.conf file under the global settings.
[HomeShare]The HomeShare section defines a share that points to a user’s home directory, allowing access over the network. It specifies the directory path, access permissions, and limits access to the specific user, ensuring that only the owner can browse and modify the contents. You can create as many shares as you need.
In this section (and any others you create hereafter) the [name] of the share, the path, and the valid users parameters will need to match your setup. The create mask and directory mask parameters ensure that only the file’s owner (htg) can access newly created files and directories within the share. Linux permissions might seem difficult to understand at first, but getting them right will help you lock stuff down that you don't want others to access.
[HTG Home]Once you have your basic smb.conf written, save it and return to the command line, then enter sudo systemctl restart smbd to restart the Samba daemon.
Finally, you simply need to add the user to Samba with sudo smbpasswd -a your_username.
Now, you should be able to access your shares from all devices on the network. There's so much more you can do with your smb.conf, and plenty of documentation explaining all the various sections and parameters you can add to it.
Whenever you do make any changes, it's helpful to type testparm to make sure the configuration is valid. Remember that every time you change the configuration, you'll need to restart Samba.
Let's go through each of the four big commercial operating systems—Windows, macOS, Android, iPhone—to show you how to now connect to your network shares.
To access your shares on Windows, simply open File Explorer and type \\NETBIOS_NAME or \\IP_ADDRESS in the location field, then you'll be prompted to enter your username and Samba password.
Alternatively, right-select the Network heading and select Map Network Drive to assign your shared network resource a drive letter in Explorer. Keep in mind, you will need to provide the full path of the Samba share, for example: "//ubuntu-vm/HTG Home".
On macOS, the most reliable way to connect to network resources is to open the Finder, select Go > Connect To Server or keyboard shortcut Cmd+K. In the empty field, enter "smb://server name" or "smb://server IP address", then Connect, and you'll be prompted to enter your username and Samba password. Make sure to select "Remember This Password In My Keychain" if you don't want to keep entering your credentials every time you connect.
You can't mount shared network resources in macOS like you can on Windows, but you can go into your computer's location in the Finder, and drag them to the sidebar to pin them for later access.
Many Android devices don't come with a stock file manager that supports the SMB protocol, so you'll need to install one that does. I'm using File Manager +, which is free and has the necessary functionality to connect to remote sources including SMB, FTP, SFTP, and WebDAV.
I selected the Local Network option, which makes it just a little bit easier to connect to your other machines because it automatically files in the Host (IP address) and Display Name (NetBIOS name).
You can connect to server resources using the Files app, which comes included on every iPhone device. The Files app is finicky about using the server name, so I had to enter the IP address to get it to connect to the server.
Setting up a Samba file server on a Linux machine offers a powerful, versatile solution for managing files across various devices and operating systems. If you're looking for other ways to share files across platforms, you can also try LocalSend, or create your own cloud server with NextCloud.
When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.
Comments