How to Share Files Between Windows and Linux Using Samba

In mixed-OS environments where Windows laptops exist alongside Linux servers or desktop machines, sharing files can initially seem daunting. You cannot simply use Apple’s AirDrop, and constantly plugging in USB flash drives is inefficient. The industry-standard solution for seamless file sharing across different operating systems over a local network is SMB (Server Message Block), and on Linux, this protocol is implemented using software called Samba.

By installing and configuring Samba on your Linux machine, you can create a shared folder that appears natively in the Windows File Explorer, allowing you to drag and drop files exactly as if they were on a local hard drive.

Step 1: Install Samba on Linux

The following steps are tailored for Ubuntu, Debian, and Linux Mint, but the core concepts apply to all distributions.

  1. Open your Linux terminal (Ctrl + Alt + T).
  2. Update your package list to ensure you get the latest version:
    sudo apt update
  3. Install the Samba package:
    sudo apt install samba
  4. Verify the installation was successful by checking the service status:
    systemctl status smbd
    It should say “active (running)”. Press Q to exit the status view.

Step 2: Create a Shared Folder

Next, you need to designate a specific directory on your Linux machine that Windows users will be allowed to access.

  1. Create a new directory (for example, in your home folder):
    mkdir ~/WindowsShare
  2. Give the folder the appropriate permissions so that network users can read and write to it:
    sudo chmod 777 ~/WindowsShare
    (Note: 777 gives everyone full read/write/execute access. For a private home network this is fine, but for enterprise environments, you should use stricter permissions).

Step 3: Configure the Samba File

You must now tell Samba where this folder is and how it should be shared.

  1. Open the Samba configuration file using a text editor (like Nano):
    sudo nano /etc/samba/smb.conf
  2. Use your down arrow key to scroll to the very bottom of the file.
  3. Add the following block of text at the end. (Replace /home/username/WindowsShare with your actual folder path):
    [LinuxShare]
        path = /home/username/WindowsShare
        read only = no
        browsable = yes
        guest ok = no
  4. Save the file by pressing Ctrl + O, then Enter, and exit using Ctrl + X.

Step 4: Create a Samba Password

Even if you are logging in with your normal Linux username, Samba uses its own separate password database for network security. You must add your Linux user to the Samba database.

  1. Run the following command (replace “username” with your actual Linux username):
    sudo smbpasswd -a username
  2. You will be prompted to enter a new password. You can use your existing Linux password or create a new one specifically for network sharing.
  3. Restart the Samba service to apply all your changes:
    sudo systemctl restart smbd

Step 5: Connect from Windows

Your Linux machine is now actively broadcasting the shared folder to your local network. You just need to connect to it from Windows.

  1. Before leaving your Linux machine, find its local IP address by typing:
    ip a
    (Look for the number next to inet under your main network adapter, usually starting with 192.168.x.x).
  2. Move to your Windows computer.
  3. Press Win + E to open File Explorer.
  4. Click in the main address bar at the very top (where it usually says “Quick access” or “This PC”).
  5. Type two backslashes followed by the Linux IP address. For example:
    \\192.168.1.50
  6. Press Enter.
  7. A Windows security prompt will appear asking for network credentials. Enter the Linux username and the Samba password you created in Step 4.
  8. Check the box that says Remember my credentials so you do not have to log in every time.
  9. Click OK.

You will now see the LinuxShare folder. You can drag files into this folder on Windows, and they will instantly appear in the ~/WindowsShare directory on your Linux machine.

Mapping the Drive (Optional)

For easier access, you can make this Linux folder appear as a permanent hard drive letter (like Z:) in Windows.

  1. Right-click the LinuxShare folder you just opened.
  2. Select Map network drive… (In Windows 11, you may need to click “Show more options” first).
  3. Choose a drive letter from the dropdown list.
  4. Ensure Reconnect at sign-in is checked.
  5. Click Finish.

The Linux share is now permanently mounted on your Windows PC, accessible instantly whenever both machines are on the same network.

Get the best tech tips delivered straight to your inbox.

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