Configure Samba to Share Users’ Home Directories
1. Install required packages
On Debian/Ubuntu systems:
sudo apt-get update
sudo apt-get install -y samba samba-common-bin openssh-server
2. Enable the per-user home share in smb.conf
Back up the current configuration, then edit it:
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup
sudo nano /etc/samba/smb.conf
Locate the [homes] section (it is usually commented out) and define it like this:
#======================= Share Definitions =======================
[homes]
comment = User Home Directories
browseable = no
read only = no
create mask = 0644
directory mask = 0755
valid users = %S
Save the file and exit the editor.
Optionally validate the configuration syntax:
sudo testparm
3. Restart Samba serivces
Use systemd (preferred on modern distributions):
sudo systemctl restart smbd nmbd
If your system uses the legacy service command:
sudo service smbd restart
sudo service nmbd restart
4. Create a Samba password for an existing user
Assume there is already a local Linux user named alice:
sudo smbpasswd -a alice
Enter a Samba password when prompted. This does not change the user’s Unix paswsord.
5. Connect from Windows
In File Explorer’s address bar, enter the UNC path to the user’s home share:
\\<server-ip-or-hostname>\alice
Note: Use the username directly, not a path like \\home\alice.
Windows will prompt for credentials. Provide the username (alice) and the Samba password set with smbpasswd.
6. Map the share as a network drive on Windows
- Open File Explorer and select This PC
- Click Map network drive on the toolbar
- Choose a drive letter
- In Folder, enter \\alice
- Check Connect using different credentials if needed, then finish