How to Install and Configure Samba on Ubuntu for File Sharing

To share files between Windows and Linux, install Samba on Ubuntu, configure a shared directory in /etc/samba/smb.conf, create a Samba password, and connect from Windows using the server's IP address. This guide covers the essential setup steps for Ubuntu server hosting environments. Whether you use USA hosting, a VPS, or dedicated server hosting, configure file permissions and firewall rules carefully, and restrict SMB access to trusted networks.

What Is Samba?

Samba is an open-source software suite that implements the SMB protocol, allowing Windows and Linux systems to share files and printers over a network. It is commonly used for centralized file storage, cross-platform collaboration, and network file sharing.

How to Install and Configure Samba on Ubuntu

Step 1: Install Samba

Connect to your Ubuntu server through SSH. If you need help connecting, see How to Connect to Linux Servers Remotely.

Update package information and install Samba:

sudo apt update
sudo apt install samba

Update Ubuntu package repositories

Install Samba on Ubuntu

Verify the installation:

whereis samba

Verify Samba installation

Step 2: Create and Configure a Shared Directory

Create a directory for shared files. This example uses /home/administrator/sambashare:

sudo mkdir -p /home/administrator/sambashare

Create a Samba shared directory

Open the Samba configuration file:

sudo nano /etc/samba/smb.conf

Edit the Samba configuration file

Add the following configuration at the end of the file:

[sambashare]
   comment = Samba on Ubuntu
   path = /home/administrator/sambashare
   read only = no
   browsable = yes

Configure the Samba share

Save the file and exit the editor. Ensure the directory has appropriate ownership and permissions for the intended users. Avoid granting unrestricted access to sensitive files.

Restart Samba and validate the configuration:

sudo testparm
sudo systemctl restart smbd
sudo systemctl status smbd

Restart the Samba service

If UFW is enabled, allow Samba traffic:

sudo ufw allow from <trusted-subnet> to any app Samba

Replace <trusted-subnet> with your trusted network, such as 192.168.1.0/24. Confirm that the Samba application profile exists on your system. For internet-facing server hosting, do not expose SMB ports directly to the public internet.

Step 3: Create a Samba User

Samba authentication requires a valid Linux system account. If the account does not exist, create it first. Then set its Samba password:

sudo smbpasswd -a administrator

Replace administrator with your actual Linux username.

Set a Samba user password

Step 4: Connect from Windows

On Windows, open This PC → Map network drive.

Open Map Network Drive

Enter the following network path, replacing the example IP address with your Ubuntu server's IP:

\\192.168.1.100\sambashare

Select Connect using different credentials, click Finish, and enter your Samba username and password.

Connect to the Linux Samba server

After authentication succeeds, you can access the shared directory from Windows.

Access shared files through Samba

Conclusion

Samba enables file sharing between Windows and Ubuntu by combining a configured SMB share, valid user credentials, and appropriate network access. For secure server hosting, verify directory permissions and limit SMB access to trusted networks. When choosing a hosting provider, consider network security and private connectivity options. A USA hosting provider may suit applications requiring US-based infrastructure, while the best USA hosting location depends on your users and network requirements.

Last Updated:   10/23/2026
Outline