File Sharing Between Ubuntu 24.04 and Windows: A Complete Guide for Desktop Users

Introduction

In recent years, the open-source operating system Linux has gained widespread use not only for servers but also in desktop environments. Among the many Linux distributions, Ubuntu has become especially popular for its beginner-friendly interface. Meanwhile, Windows has long reigned as the mainstream desktop OS.

As a result, it’s now common to find mixed environments where Linux and Windows coexist. The need to share files between PCs with different operating systems is growing. However, because Linux and Windows have different file systems and management approaches, setting up file sharing can be confusing for many.

In this article, I’ll explain how to share files between the latest Ubuntu 24.04 LTS and Windows 10 (and later). Focusing mainly on GUI-based operations within a desktop environment, I’ll also cover some command-line settings.

Throughout the article, I’ll also share real-world errors I encountered and the solutions I found. These insights should be helpful for readers facing similar issues.

Although sharing files between Linux and Windows may initially seem complicated, with the right settings and understanding, it’s entirely manageable. I hope this article helps you learn the basic concepts and practical steps for file sharing between Ubuntu 24.04 and Windows.

Now, let’s start by setting up file sharing on the Ubuntu side.

TOC

Prerequisites

To follow along with this guide, you’ll need:

  • Ubuntu 24.04 LTS Desktop installed on one PC
  • Windows 10 or later on another PC
  • Both PCs connected to the same local network (LAN)

Setting Up File Sharing on Ubuntu (GUI)

To set up file sharing in Ubuntu 24.04’s desktop environment, I first tried to right-click on the folder I wanted to share. In previous versions, there was an option called “Local Network Share,” but I couldn’t find it this time. Wondering what had changed, I decided to dig a bit deeper.

After some research, I discovered that Ubuntu 24.04 has changed its file-sharing setup process. Here are the new steps:

  1. Open the App Center, search for “Samba”, and install the Samba filesharing plugin (Debian version).
  2. Open Terminal and enter the following command to install the “nautilus-share” package:
    sudo apt install nautilus-share
  3. Restart your system.

After restarting, if you right-click on the folder you want to share, you should now see an option called “Sharing Options”.

With this change, the setup now uses a different package than previous versions. Samba has traditionally been the software used for file sharing, but nautilus-share is a package that extends the sharing capabilities of the Nautilus file manager. In simple terms, “nautilus-share” lets you share selected folders directly with other users from the context menu within Nautilus, primarily through Samba for compatibility with Windows networks.

By combining these packages in Ubuntu 24.04, it seems possible to configure file sharing more seamlessly. Additionally, renaming “Local Network Share” to “Sharing Options” clarifies the function’s purpose.

Although the new method may feel unfamiliar at first, following these steps should make it easy to set up file sharing on Ubuntu 24.04. In the next section, I’ll walk you through the actual steps to configure file sharing using the “Sharing Options.”

Configuring File Sharing Using “Sharing Options”

Once the “Sharing Options” appears (as outlined in the previous section), you’re ready to set up file sharing.

  1. Right-click on the folder you want to share and select “Sharing Options”.
  2. The Sharing Options dialog box will open, showing several settings:
    • “Share this folder”: Check this box to share the selected folder.
    • “Share name”: Set a name for the shared folder. By default, it uses the folder name.
    • “Comment”: Optionally, add a description for the shared folder.
    • “Allow others to create and delete files in this folder”: Enable this if you want other users to modify files in the folder.
    • “Guest access (for people without a user account)”: Enable this to allow access to the folder without user authentication.
  3. After setting your preferences, click “Create Share”.

If the sharing is successfully created, you’ll notice the folder icon changes, indicating that the folder is now shared. However, when I clicked “Create Share,” I encountered an error message:

'net usershare' returned error 255: net usershare: cannot open usershare directory /var/lib/samba/usershares. Error Permission denied
You do not have permission to create a usershare. Ask your administrator to grant you permissions to create a share.

This message indicates that additional permissions are required. In the next section, I’ll explain how to resolve this error.


Troubleshooting File Sharing Errors

If you encounter the following error while setting up file sharing, here’s how to fix it:

'net usershare' returned error 255: net usershare: cannot open usershare directory /var/lib/samba/usershares. Error Permission denied
You do not have permission to create a usershare. Ask your administrator to grant you permissions to create a share.

This error appears because the current user doesn’t have permission to create a file share. Follow these steps to resolve it:

  1. Open Terminal and add the current user to the Samba group by entering:
    sudo usermod -a -G sambashare $USER
  2. Set a Samba password for the current user:
    sudo smbpasswd -a $USER
  3. Log out and log back in to apply the changes.
  4. Once logged back in, right-click the folder you want to share and select “Sharing Options” again.
  5. Configure your settings and click “Create Share”.

If the error still isn’t resolved, you may need to restart the Samba service:

sudo systemctl restart smbd

Once the Samba service has restarted, try the steps again to create the share.

If these steps do not resolve the issue, additional configuration changes may be necessary, which I’ll cover next.

Additional Troubleshooting Steps for File Sharing Errors

If you still see the error after restarting Samba, try the following steps to modify Samba’s configuration:

  1. Open Terminal and edit the Samba configuration file:
    sudo nano /etc/samba/smb.conf
  2. Scroll to the end of the file and add the following line to allow shared folders to be created by users other than the owner:
    usershare owner only = false
  3. Press Ctrl+O to save your changes, then Ctrl+X to exit the editor.
  4. Restart the Samba service again to apply the changes:
    sudo systemctl restart smbd
  5. Right-click on the folder you want to share, select “Sharing Options”, configure the settings, and click “Create Share”.

If this doesn’t resolve the issue, you may need to adjust permissions on the usershare directory:

  1. Open Terminal and change the ownership and group permissions of the /var/lib/samba/usershares directory:
    sudo chown root:sambashare /var/lib/samba/usershares
  2. Next, set group write permissions for the directory:
    sudo chmod 1770 /var/lib/samba/usershares
  3. To apply these changes, restart Nautilus or reboot the system
    nautilus -q
    Note: If the nautilus -q command shows a message like this:
    Connecting to org.freedesktop.Tracker3.Miner.Files
    Don’t worry. This is not an error. It simply means Nautilus is trying to communicate with Tracker (a file indexing and search service). You can ignore this message as long as Nautilus restarts properly.

After following these steps, you should have the correct permissions set up to use the shared directory in Samba.


Setting Folder Permissions for File Sharing

When sharing files with Samba, you’ll need to ensure the shared folder has appropriate permissions. Typically, setting permissions to 755 or 775 is recommended. These permissions allow the folder owner full access while other users have read-only access.

However, setting permissions to 777 (full access for all users) may sometimes lead to security issues or errors. During testing, I found that enabling file sharing on folders with 777 permissions caused an error in the GUI.

To set folder permissions in the GUI:

  1. Right-click on the folder you want to share and select “Properties”.
  2. Go to the Permissions tab and set the following permissions:
    • Owner: Create and delete files
    • Group: Access files
    • Others: Access files
  3. Click Close to save the settings.

These permissions should allow Samba to share files without issues. However, note that enabling sharing through the GUI may still apply 777 permissions automatically.


Configuring for Japanese Folder Names (if needed)

To support sharing folders with Japanese names, it’s best to first attempt sharing without changing any encoding settings. If issues arise, you can configure Samba’s settings to support Japanese characters. This can help ensure that Japanese folder and file names display correctly.

  1. Open Terminal and edit the Samba configuration file:
    sudo nano /etc/samba/smb.conf
  2. In the [global] section, add the following lines:
    # Encoding settings for Japanese folder names
    unix charset = UTF-8
    dos charset = CP932
    display charset = UTF-8
    • unix charset = UTF-8: Sets UTF-8 as the encoding for Linux.
    • dos charset = CP932: Enables Shift-JIS encoding (for Japanese) when connecting to Windows clients.
    • display charset = UTF-8: Configures UTF-8 for internal Samba display, supporting Japanese characters.
  3. Save the file and exit the editor.
  4. Restart the Samba service to apply the new settings:
    sudo systemctl restart smbd

Try sharing a folder with a Japanese name again. With these settings, Japanese folder and file names should now display correctly, making the sharing function as expected.

Manual Configuration of Samba for File Sharing

If the GUI method for configuring file sharing does not resolve errors, you can manually edit the Samba configuration file and set up users yourself.

  1. Open Terminal and edit the Samba configuration file:
    sudo nano /etc/samba/smb.conf
  2. Scroll to the end of the file, and add a new section to define the shared directory:
    [Share_Name]
    path = /path/to/shared/folder
    read only = no
    browsable = yes
    • [Share_Name]: This is the name that will appear when accessing the share from Windows.
    • path: Replace this with the actual path of the folder you wish to share.
  3. Press Ctrl+O to save the changes, then Ctrl+X to exit the editor.
  4. Restart the Samba service to apply the new settings:
    sudo systemctl restart smbd

Once configured, you should be able to access the shared folder from Windows by using the specified share name. While GUI settings are generally preferred for ease, manually editing the configuration file can give you greater control over share settings.


Connecting from Windows

Once file sharing is configured on the Ubuntu side, you can access the shared folder from your Windows PC.

  1. Open File Explorer in Windows.
  2. In the address bar, enter the following path:
    \\<Ubuntu_PC_IP_Address>
  3. Press Enter, and the shared folder should appear.
  4. If prompted for a username and password, enter the Ubuntu user credentials.

Troubleshooting Guest Access Issues

If you’ve enabled guest access but are still prompted for login credentials, it may indicate that guest access isn’t fully enabled in Samba. To adjust the configuration:

  1. Open Terminal and edit the Samba configuration file:
    sudo nano /etc/samba/smb.conf
  2. In the section for the shared folder, add or confirm the following settings:
    [Share_Name]
    path = /home/username/Documents
    read only = no
    browsable = yes
    guest ok = yes
    force user = username
    • guest ok = yes: Allows guest users to access the folder.
    • force user = username: Ensures that all access is conducted under the specified user, allowing access without login.
  3. Save the file and exit the editor.
  4. Restart the Samba service:
    sudo systemctl restart smbd

After making these adjustments, you should be able to access the shared folder from Windows without needing to log in. Test the access again to confirm that guest access is working properly.

Verifying and Configuring Firewall Settings

When sharing files on Ubuntu, improper firewall settings can prevent access from Windows. Here’s how to check and configure the firewall to allow file sharing:

  1. Check if the firewall is active by entering:
    sudo ufw status
  2. If the firewall is active, you’ll need to allow Samba traffic. Enter the following commands to open the necessary ports:
    sudo ufw allow Samba
  3. Once completed, check the firewall status to confirm that Samba is allowed:
    sudo ufw status

This configuration should enable Windows devices to access shared folders on your Ubuntu machine. Remember, firewall settings may need to be adjusted if you’re running any additional security software.


Disabling Guest Access and Enforcing User Authentication

For security reasons, you may prefer to disable guest access and allow only specific users to access shared folders. Here’s how to enforce user authentication:

  1. Open Terminal and edit the Samba configuration file:
    sudo nano /etc/samba/smb.conf
  2. Locate the section for the shared folder (e.g., [Share_Name]) and add or update the following settings:
    [Share_Name]
    path = /home/username/Documents
    read only = no
    guest ok = no
    valid users = username
    • guest ok = no: Disables guest access.
    • valid users = username: Restricts access to the specified user only. Replace username with the desired Ubuntu user.
  3. Save the file and exit the editor.
  4. Restart the Samba service:
    sudo systemctl restart smbd

With this setup, only the specified user (in this example, username) will have access to the shared folder. When accessing from Windows, you’ll need to enter this username and password.


Important Note: Matching Windows and Ubuntu Credentials

If the Windows and Ubuntu usernames and passwords are the same, Windows may automatically attempt to connect using these credentials, bypassing the login prompt. This can be convenient, but it may also lead to issues if you want a different user to log in.

To force Windows to prompt for login credentials:

  1. Open the Windows Credential Manager.
  2. Remove any saved credentials for the Ubuntu machine.

This should trigger the login prompt the next time you access the shared folder, allowing you to manually enter different credentials if needed.

Accessing Windows or Other Shared Folders from Ubuntu

To access shared folders on Windows or other systems from your Ubuntu desktop, you have two options: using the File Manager (GUI) or accessing via Terminal commands.


1. Accessing Shared Folders with the File Manager (GUI)

  1. Open your file manager (usually called “Files” or “Nautilus” in Ubuntu).
    • The file manager in Ubuntu, similar to Windows Explorer, lets you view and manage files, and also provides access to network-shared folders.
  2. In the file manager sidebar, select “Other Locations”.
  3. In the Connect to Server field at the bottom of the screen, enter the following path:
    smb://<IP_Address_of_Shared_Device>/
    • For example: smb://192.168.1.10/
  4. Click Connect, and if prompted, enter the username and password for the shared folder.

Once connected, the shared folder should be accessible from your file manager, allowing you to browse and manage files directly.


2. Accessing Shared Folders via Terminal (Using smbclient)

To access a shared folder through the Terminal, you can use the smbclient command, which provides a similar interface to FTP.

  1. First, ensure smbclient is installed. If not, install it by entering:
    sudo apt update
    sudo apt install smbclient
  2. Connect to the shared folder using smbclient:
    smbclient //<IP_Address_of_Shared_Device>/<Shared_Folder> -U <username>
    • For example: smbclient //192.168.1.10/Documents -U username
  3. When prompted, enter the password for the specified user.

Once connected, you can use FTP-like commands to interact with files in the shared folder. Here are a few useful commands:

  • ls: List files in the directory
  • get filename: Download a file
  • put filename: Upload a file

You’ll know you’re successfully connected if you see a prompt similar to:

smb: \>

To confirm where files will be saved, use the pwd command to check your current working directory, or set a specific local directory using lcd before downloading files.

Handling File Names with Spaces

When using smbclient to download files, you may encounter issues if the file names contain spaces. For example, trying to download a file named 2024-10-30 17-22-24.mkv might produce an error like this:

smb: \> get 2024-10-30 17-22-24.mkv
NT_STATUS_OBJECT_NAME_NOT_FOUND opening remote file \2024-10-30

This error occurs because smbclient does not recognize the entire file name due to the spaces. You can resolve this in one of two ways:

  1. Use Quotation Marks: Enclose the file name in double or single quotes:
    get "2024-10-30 17-22-24.mkv"
  2. Escape Spaces with a Backslash: Place a backslash (\) before each space in the file name:
    get 2024-10-30\ 17-22-24.mkv

These methods will help smbclient correctly interpret the entire file name, allowing you to download the file successfully.


Making Your Ubuntu Machine Visible on the Windows Network

While Ubuntu is accessible from Windows by entering its IP address, it may not automatically appear in the Windows network list. To make it more discoverable, you can install wsdd2 (Web Services Dynamic Discovery), which helps Ubuntu appear in Windows network lists.

  1. Install wsdd2 by following the instructions on its GitHub page:
    sudo apt install wsdd2
  2. After installation, Ubuntu should appear in the Windows network list, assuming your firewall settings allow it.
    Note: This setup was confirmed with the firewall disabled. If your firewall is active, additional configuration may be necessary to allow network discovery.
  3. For Windows visibility, ensure SMB 1.0/CIFS File Sharing Support is enabled.

With wsdd2 running, you should see your Ubuntu machine listed on the Windows network, allowing for seamless access.

Checking and Configuring Firewall Settings for File Sharing

When using wsdd2 or Samba for file sharing, your firewall must be configured to allow the necessary ports. Here’s a quick guide to ensuring everything is set up correctly.

Ports Used by wsdd2

wsdd2 requires specific ports for device discovery and access:

  • WSD (Web Services for Devices):
    • Multicast Address: 239.255.255.250 and ff02::c
    • Protocol: UDP
    • Port: 3702
    • Unicast SOAP HTTP WS-Discovery responder: TCP Port 3702
  • LLMNR (Link-Local Multicast Name Resolution):
    • Multicast Address: 224.0.0.252 and ff02::1:3
    • Protocol: UDP
    • Port: 5355
    • Unicast responder: TCP Port 5355

Make sure these ports are open in your firewall to allow wsdd2 to function properly.

Configuring the Firewall

To configure the firewall to allow these ports, follow these steps:

  1. Check Firewall Status:
    sudo ufw status
  2. Allow Required Ports:Open each of the ports required by wsdd2:
    sudo ufw allow 3702/udp
    sudo ufw allow 3702/tcp
    sudo ufw allow 5355/udp
    sudo ufw allow 5355/tcp
  3. Enable Samba Access:Additionally, allow Samba traffic if it’s not already permitted:
    sudo ufw allow Samba
  4. Confirm the Firewall Status:After configuring, check the firewall status to ensure all necessary rules are active:
    sudo ufw status

These steps should ensure that both wsdd2 and Samba can communicate through the firewall, making your Ubuntu machine visible to Windows devices on the network.


Summary

In this guide, we covered the complete process for setting up file sharing between Ubuntu 24.04 and Windows. Here’s a quick recap of the key steps:

  1. Prepare Ubuntu: Install Samba and nautilus-share to enable file sharing.
  2. Configure File Sharing: Use “Sharing Options” to share folders, or edit the Samba configuration manually if needed.
  3. Troubleshoot Issues: Address common errors by adjusting permissions, adding users to Samba, or manually configuring Samba settings.
  4. Enable Japanese Folder Support: Adjust encoding settings in Samba to properly display Japanese folder names, if necessary.
  5. Connect from Windows: Access shared Ubuntu folders from Windows File Explorer by entering the Ubuntu machine’s IP.
  6. Access Windows Folders from Ubuntu: Use the file manager or smbclient to connect to shared Windows folders.
  7. Improve Network Visibility: Install wsdd2 to make your Ubuntu machine appear on Windows network lists.
  8. Configure the Firewall: Allow the necessary ports for wsdd2 and Samba to ensure smooth file-sharing access.

By following these steps, you should now have a reliable and secure file-sharing setup between Ubuntu and Windows. For any future troubleshooting or configuration adjustments, refer back to this guide to maintain and enhance your file-sharing environment.

Please share if you like it!
TOC