How to Share Files Between Windows and Linux Using Samba

Running a mixed-OS environment where both Linux and Windows machines operate on the same local network is incredibly common. However, moving files between them can often feel like a massive headache. You could use a USB flash drive to physically move data, or upload files to a cloud service just to download them on the machine sitting next to you. Both methods are slow, inefficient, and unnecessary.

The most robust and professional way to share files across a local network between Linux and Windows is by using Samba. Samba is an open-source implementation of the SMB (Server Message Block) networking protocol, which is the native file-sharing system used by Windows. By installing Samba on your Linux machine, you can create a shared folder that appears natively in the Windows File Explorer, allowing you to drag, drop, read, and write files instantly.

Here is a step-by-step guide on how to configure a Samba share on Ubuntu Linux and access it from Windows 11.

## Step 1: Install Samba on Linux

Before you can configure a share, you must install the Samba service on your Linux machine. This guide uses Ubuntu, but the process is nearly identical for Debian-based distributions.

1. Open a terminal window on your Linux machine.
2. Update your package list to ensure you are downloading the latest software versions:
`sudo apt update`
3. Install the Samba package by running the following command:
`sudo apt install samba`
4. When prompted, type `Y` and press Enter to confirm the installation.

Once the installation finishes, the Samba service will start automatically in the background.

## Step 2: Create a Shared Directory

Next, you need to choose or create a folder on your Linux machine that will act as the bridge between the two operating systems.

1. Decide where you want the folder. For this example, we will create a folder called `SharedFolder` in the home directory.
`mkdir ~/SharedFolder`
2. You need to ensure that Samba has the correct permissions to read and write to this folder. To grant full access, use the `chmod` command:
`chmod 777 ~/SharedFolder`

*Security Note: Using `777` grants read, write, and execute permissions to everyone. This is fine for a private home network, but on a public or corporate network, you should restrict permissions strictly to authorized users.*

## Step 3: Configure the Samba Share

Now you must tell the Samba service that this specific folder should be broadcast over the network. To do this, you will edit the main Samba configuration file.

1. Open the Samba configuration file using a text editor like Nano:
`sudo nano /etc/samba/smb.conf`
2. Use the arrow keys to scroll all the way to the very bottom of the file.
3. Add the following block of text, which defines the rules for your new share:

“`
[WindowsShare] path = /home/your_username/SharedFolder
read only = no
browsable = yes
guest ok = yes
“`
*(Be sure to replace `your_username` with your actual Linux username).*

4. Save the file and exit the editor. In Nano, press **Ctrl + O**, hit **Enter** to save, and then press **Ctrl + X** to exit.

## Step 4: Restart the Samba Service

For the changes in the configuration file to take effect, you must restart the Samba service.

1. Run the following command in the terminal:
`sudo systemctl restart smbd`

Your Linux machine is now actively sharing the folder over the local network.

## Step 5: Find Your Linux IP Address

To access the folder from Windows, you need to know the IP address of your Linux machine on the local network.

1. Run the `ip` command:
`ip a`
2. Look for the active network interface (usually starting with `en` for Ethernet or `wl` for Wi-Fi).
3. Find the `inet` address. It will typically look something like `192.168.1.15`. Write this number down.

## Step 6: Access the Shared Folder from Windows

Now move over to your Windows PC to access the files.

1. Open **File Explorer** in Windows.
2. Click on the address bar at the very top of the window.
3. Type two backslashes followed by the Linux IP address you found in Step 5. For example:
`\\192.168.1.15`
4. Press **Enter**.

A window will open displaying the shared folder you created (named `WindowsShare` based on our configuration file). You can now open this folder and drag and drop files exactly as if they were on your local hard drive.

### Mapping the Network Drive for Permanent Access

If you plan to use this folder frequently, you should map it as a network drive so it appears permanently in your “This PC” menu under a designated drive letter.

1. Right-click on the `WindowsShare` folder in File Explorer.
2. Select **Show more options** (if on Windows 11), then click **Map network drive…**
3. Choose a drive letter from the drop-down menu (e.g., `Z:`).
4. Ensure the **Reconnect at sign-in** box is checked.
5. Click **Finish**.

You have now established a permanent, high-speed file transfer bridge between your Linux and Windows machines.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.

Receive our best articles and tips delivered straight to your inbox.