How to Setup and Mount Samba Share on Windows

How to Setup and Mount Samba Share on Windows

A folder on a Linux computer can be hard to reach from Windows until you share it over the network. Samba lets Linux share files with Windows over SMB, using a name that Windows can open in File Explorer.

This article shows how to configure an authenticated share on Ubuntu or Debian and connect to it from Windows.

TL;DR

Install Samba on the Linux host, define a named share in smb.conf, add an SMB password for an existing Linux account, then open \\server-address\share-name in Windows File Explorer.

  • Use an authenticated share, not guest access.
  • The Linux folder’s permissions still limit what the SMB user can do.

What is a Samba share?

Samba is a Linux service that shares files with Windows through the SMB protocol. A section in its configuration assigns a network name to a Linux directory, while the account and directory permissions determine what a connecting user can access.

For example, a section named [shared] can expose /home/alex/shared as the Windows path “\\server\shared”. The share setting grants no more access than the Linux account has on that directory, so the Linux permissions remain part of the access check. A user needs folder access as well as a valid SMB password.

These commands target Ubuntu or Debian and create an authenticated user share. For broader installation and configuration coverage, see our Samba setup guide for Linux, which covers the Linux-side service setup.

What you need before setting up the share

The Linux computer and Windows computer must be able to reach each other on the same local network or through a trusted routed network. You also need a Linux account, a directory you are allowed to share, and the server’s IP address or a hostname Windows can resolve.

  • Choose a folder whose contents are appropriate for network access.
  • Use an existing Linux account for the Samba login. Samba keeps a separate password for that account.
  • If the host address changes, a stable local IP address or a DHCP reservation helps keep the Windows path valid.

How to set up a Samba share and map it in Windows

Set up the Linux folder and SMB account first, then enter the share’s UNC path in Windows. A UNC path uses two leading backslashes, followed by the server name or address and the share name.

Step 1: Install Samba on Ubuntu or Debian

Install the server package on the Linux computer that will hold the files. These package commands are for Ubuntu and Debian systems.

sudo apt update
sudo apt install samba

Ubuntu and Debian install the Samba server components and use /etc/samba/smb.conf for configuration, while other distributions may use different package managers and service names.

Step 2: Create a directory and define the share

Create a directory for files you intend to expose, then add a share section to the end of /etc/samba/smb.conf. Replace the example Linux username with the account that should access the directory.

mkdir -p "$HOME/sambashare"
sudo nano /etc/samba/smb.conf

Add this configuration, changing the path so it matches the actual Linux home directory and account:

[sambashare]
    path = /home/linux-user/sambashare
    browsable = yes
    read only = no
    guest ok = no

[sambashare] becomes the share name Windows requests. The setting “read only = no” permits writes at the Samba layer, but the Linux account still needs filesystem permission to write to the folder. Keep “guest ok = no” so the connection requires an account.

Step 3: Add the SMB password and validate the configuration

Add the Linux account to Samba’s password database. The account must already exist on the server, and the SMB password can differ from its Linux login password.

sudo smbpasswd -a linux-user
sudo testparm -s /etc/samba/smb.conf
sudo systemctl restart smbd

Replace linux-user with the account name. The first command prompts you to enter and confirm an SMB password.

The configuration check reports whether Samba can parse the file, and restarting the service after editing loads the share into the server.

If UFW is enabled, allow Samba only from the subnet used by your trusted LAN. Replace the example network range with your own subnet:

sudo ufw allow from 192.168.0.0/24 to any app Samba

The subnet-specific rule avoids opening the share to every source that can reach the host. Do not forward SMB ports from a home router to expose the share to the public internet.

Step 4: Open the share from Windows

In File Explorer, choose This PC, select Map network drive, choose a drive letter, and enter \\server-address\sambashare in the Folder field. Replace server-address with the Linux host’s IP address or a resolvable hostname. Select Finish and enter the Linux account name and SMB password if Windows asks for credentials.

Windows Map Network Drive dialog with a UNC path for a Samba share
The Map Network Drive dialog uses a UNC path. This older capture shows Windows attempting a connection, not a confirmed successful mount.

The network path uses the server address and share name, not the Linux directory path. If you enable Reconnect at sign-in, Windows tries the mapping again at a later sign-in, so the Linux host must be reachable then.

Fix path and permission errors

A network-path error and an access-denied error point to different parts of the connection. Check the server address and share name first. Then check the account and Linux directory permissions.

Windows symptomCheck on the Linux host
Network path not foundConfirm the IP or hostname, share spelling, Samba service, and local firewall rule.
Credentials rejectedUse the Linux account name and the password set with smbpasswd.
Share opens but files are deniedCheck that the Linux account can traverse and read or write the backing directory.
Drive mapping works only until sign-outReview the reconnect option and whether the server address remains reachable.

Samba does not override the host filesystem’s permissions. Avoid fixing a denied write by making the directory writable by every local user. Grant access to the intended Linux account or group instead.

For Windows network connectivity settings, our Ubuntu network configuration guide covers the host-side network context.

Conclusion

An authenticated share gives Windows a named route to a Linux folder, while the Linux account’s permissions decide what that user can change. Keep the firewall rule limited to trusted network access and avoid exposing SMB directly to the internet.

For further configuration options, use the Samba smb.conf manual and Ubuntu’s Samba server setup guide.

sudo ufw status

Frequently asked questions

These answers cover the Windows path format, Samba credentials and the Linux folder permissions behind a share.

What path do I enter in Windows for a Samba share?

Enter the UNC path \\server-address\share-name, replacing the server address and share name with the values configured on the Linux host.

Do I use my Linux password to connect to Samba?

Use the Samba password set for an existing Linux account with smbpasswd. It can be different from that account’s Linux login password.

Why can I open a Samba share but not write files?

The share’s Samba settings and the Linux filesystem permissions both apply. The connecting Linux account needs write permission on the backing directory.