Ubuntu 24.04 and Windows File Sharing: Overcoming Challenges and Achieving Seamless Integration

Introduction

In recent years, Linux, an open-source operating system, has gained popularity not only for server use but also in desktop environments. Ubuntu, in particular, has become a favorite Linux distribution among beginners due to its user-friendly interface. On the other hand, Windows has long been the dominant desktop OS.

In such a situation, it’s not uncommon to find environments where Linux and Windows coexist. The need to share files between PCs running different operating systems is growing. However, since Linux and Windows have different file systems and management methods, many people may be confused about how to set up file sharing.

This article will explain how to share files between the latest Ubuntu 24.04 LTS and Windows 10 or later. We’ll focus on GUI operations in the desktop environment and also touch on command-line settings.

As we progress through the article, we’ll introduce actual errors that occurred in the environment and how to solve them. This information will be a valuable reference for readers who face similar problems.

Sharing files between Linux and Windows may seem complicated at first glance. However, with proper setup and understanding, it’s not difficult at all. Through this article, we hope you’ll learn the basic concepts and practical methods for file sharing between Ubuntu 24.04 and Windows.

Let’s start with the file sharing settings on the Ubuntu side.

table of contents

Prerequisites

  • Ubuntu 24.04 LTS Desktop version
  • Windows 10 or later PC
  • Both PCs are connected to the same LAN

File Sharing Settings on Ubuntu (GUI)

When I tried to set up file sharing in the Ubuntu 24.04 desktop environment, I right-clicked on the folder I wanted to share. In previous versions, there was an option called “Local Network Share” here, but I couldn’t find it. Thinking it was odd, I decided to look for another method.

After some research, I discovered that the method for setting up file sharing has changed significantly in Ubuntu 24.04. The new procedure is as follows:

  1. Search for “Samba” in the App Center and install the Debian package “Samba filesharing plugin”.
  2. Open a terminal and enter the following command to install the “nautilus-share” package:
sudo apt install nautilus-share
  1. Restart the system.

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

This change means that different packages are now used to set up file sharing compared to previous versions. Samba is a software that has long been used for file sharing, while nautilus-share is a package that extends the sharing functionality of the Nautilus file manager. To explain in more detail, “nautilus-share” is an extension for Nautilus, the file manager in the GNOME desktop environment, that allows users to easily set up sharing of files and folders on the network directly from the context menu. It primarily enables sharing compatible with Windows networks via Samba.

In Ubuntu 24.04, combining these packages may have enabled a more seamless file sharing setup. Additionally, changing the name from “Local Network Share” to “Sharing Options” may have made the purpose of the feature clearer.

While it may be confusing at first, if you follow the new method, setting up file sharing in Ubuntu 24.04 is easy. In the next section, we’ll explain in detail how to set up file sharing using “Sharing Options”.

Setting Up File Sharing Using “Sharing Options”

Once you’ve followed the steps in the previous section and “Sharing Options” is displayed, let’s actually 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 appear. It contains the following settings:
  • “Share this folder”: Check this option to share the selected folder.
  • “Share name”: Set the name of the shared folder. By default, the folder name is used.
  • “Comment”: Enter a description of the shared folder. This is optional.
  • “Allow others to create and delete files in this folder”: Check this option to allow other users to modify files within the folder.
  • “Guest access (for people without a user account)”: Check this option to allow access to the folder without user authentication.
  1. After making the necessary settings, click the “Create Share” button.

If the share is created successfully, the folder icon will change to indicate that it is shared. However, when I clicked “Create Share”, the following error was displayed:

'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.

In this case, additional settings are required. In the next section, we’ll explain how to resolve this error.

Resolving File Sharing Errors

If you encounter the following error while setting up file sharing according to the steps described in the previous section, here’s how to resolve 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 occurs because the current user does not have permission to create file shares. You can solve this problem by following these steps:

  1. Open a terminal and enter the following command to add the current user to the sambashare group:
sudo usermod -a -G sambashare $USER
  1. Next, enter the following command to set the Samba password for the current user:
sudo smbpasswd -a $USER
  1. Log out and log back in to reflect the changes.
  2. Again, right-click on the folder you want to share and select “Sharing Options”.
  3. Make the necessary settings and click “Create Share”.

However, the error still doesn’t seem to be resolved. It appears that the following steps are also necessary:

  1. Open a terminal and enter the following command to restart the Samba service:
sudo systemctl restart smbd
  1. Again, right-click on the folder you want to share and select “Sharing Options”.
  2. Make the necessary settings and click “Create Share”.

If the error persists even after this, try the following steps:

  1. Open a terminal and enter the following command to edit the Samba configuration file:
sudo nano /etc/samba/smb.conf
  1. Add the following line at the end of the configuration file:
usershare owner only = false
  1. Press Ctrl+O to save the changes and Ctrl+X to exit the nano editor.
  2. Enter the following command to restart the Samba service:
sudo systemctl restart smbd
  1. Again, right-click on the folder you want to share and select “Sharing Options”.
  2. Make the necessary settings and click “Create Share”.

However, if the error still doesn’t resolve with this method, try the following steps:

  1. Open a terminal and enter the following command to change the owner and group of the /var/lib/samba/usershares directory:
sudo chown root:sambashare /var/lib/samba/usershares
  1. Next, enter the following command to give write permissions to the group for the /var/lib/samba/usershares directory:
sudo chmod 1770 /var/lib/samba/usershares
  1. To apply the configuration changes, enter the following command to restart Nautilus or reboot the system:
nautilus -q
  1. After restarting, right-click on the folder again and select “Sharing Options” to check the settings.

** Message: 19:33:29.006: Connecting to org.freedesktop.Tracker3.Miner.Files

The “Connecting to org.freedesktop.Tracker3.Miner.Files” message displayed when running the nautilus -q command is usually not an error but indicates that Nautilus is attempting to communicate with Tracker (a file indexing and search service). You can safely ignore this message. Even if this message remains displayed, as long as Nautilus has restarted correctly, it will not affect the sharing settings.

These steps set the appropriate permissions for the Samba share directory, but folder settings are also required.

Setting Folder Permissions

When sharing files with Samba, the shared folder’s permissions must be set appropriately. Typically, it is recommended to set the folder permissions to 755 or 775. With these permissions, the folder owner has read and write access, while other users have read-only access.

777 permissions may be excessive and can sometimes restrict Samba sharing for security reasons. In fact, when attempting to share a folder with 777 permissions via the GUI, an error occurred.

To change folder permissions via the GUI, follow these steps:

  1. Right-click on the folder you want to share and select “Properties”.
  2. Select the “Permissions” tab.
  3. Set the permissions as follows:
  • Owner:
    • Access: Create and Delete Files
  • Group:
    • Access: Access Files
  • Others:
    • Access: Access Files
  1. Click the Close button.

These permission settings should allow file sharing with Samba to function properly. However, when sharing, the permissions become 777.

Settings to Support Japanese Folder Name Sharing (if needed)

First, I recommend attempting to share a folder with a Japanese name without changing the character encoding settings and only modifying the settings if a problem occurs. To support Japanese folder name sharing, it may be worthwhile to adjust the encoding in the Samba settings for Japanese compatibility. By following these steps to modify the settings, Japanese folder and file names may be displayed correctly.

  1. Open a terminal and enter the following command to edit the Samba configuration file (smb.conf):
sudo nano /etc/samba/smb.conf
  1. In the [global] section, add the following settings:
# Character encoding settings for Japanese folder support
unix charset = UTF-8
dos charset = CP932
display charset = UTF-8
  • unix charset = UTF-8: Sets the character encoding to UTF-8 for use on the Linux side.
  • dos charset = CP932: Sets the character encoding to Shift-JIS (Japanese compatible) for Windows clients connecting.
  • display charset = UTF-8: Sets Samba’s internal display to UTF-8 to support Japanese display.
  1. Save the settings and close the file.
  2. Enter the following command to restart the Samba service and apply the settings:
sudo systemctl restart smbd
  1. Attempt sharing a folder with a Japanese name again.

These settings should allow Japanese folder and file names to be displayed correctly and sharing to function properly.

The settings above may not be typical for English-speaking users, but should only be used if there is a need to share folders with Japanese names. When using Samba in a Japanese environment, adding Japanese-compatible character encoding settings can help display Japanese folder and file names correctly.

It is recommended to attempt sharing with Japanese folder names without adjusting the character encoding settings first. Only if an issue arises should the character encoding settings be modified.

Manual Samba Configuration

If the error persists with the GUI file sharing settings, try directly editing the Samba configuration file and manually setting up users.

  1. Open a terminal and enter the following command to edit the Samba configuration file:
sudo nano /etc/samba/smb.conf
  1. At the end of the configuration file, add the settings for the directory you want to share, similar to the following:
[share name]
path = /path/to/shared/folder
read only = no
browsable = yes
  • “share name” is the name used when accessing from Windows.
  • Replace “path” with the actual path of the directory you want to share.
  1. Press Ctrl+O to save the changes and Ctrl+X to exit the nano editor.
  2. Finally, enter the following command to restart the Samba service and apply the settings:
sudo systemctl restart smbd

With this, the manual Samba configuration is complete. You should be able to access the shared folder from Windows using the “share name” you just set up. While I wanted to resolve the error with GUI settings as much as possible, it’s also possible to set it up manually.

In the next section, we’ll finally explain how to connect from Windows. Once the Samba setup is complete, let’s check if you can actually access it from the Windows side.

Connecting from Windows

Once the file sharing setup is complete on the Ubuntu side, let’s try accessing the shared folder from the Windows side.

  1. Open Windows Explorer and enter the following in the address bar:
\\<IP address of the Ubuntu machine>
  1. Press the Enter key, and the folders shared on the Ubuntu side will be displayed.
  2. Double-click the shared folder, and you may be prompted for a username and password. If so, enter the existing user information on Ubuntu to log in.

Troubleshooting Guest Access

If you have allowed guest access but the login screen still appears, the Samba settings may not fully allow guest access. Follow these steps to check and modify the settings if necessary.

  1. Open a terminal and enter the following command to edit the Samba configuration file (smb.conf):
sudo nano /etc/samba/smb.conf
  1. Check if the following settings are correctly added to the section of the shared folder in question:
[share name]
path = /home/mamu/Documents
read only = no
browsable = yes
guest ok = yes
force user = mamu
  • guest ok = yes allows guest user access.
  • force user = mamu forces all access to the specified user (in this example, mamu), allowing access without authentication.
  1. Save the settings and close the file.
  2. Enter the following command to restart the Samba service and apply the settings:
sudo systemctl restart smbd

Now, authentication should not be required when accessing from Windows. Try accessing again from the Windows side to check if guest access is functioning properly.

Adding this content to the article will allow readers to learn how to troubleshoot when guest access is not working. They will also gain a deeper understanding of how to edit the Samba configuration file and the specific settings required to enable guest access.

In the next section, we’ll discuss checking the firewall. Even if file sharing is set up on the Ubuntu side, if the firewall is not configured properly, access from Windows may not be possible.

Disabling Guest Access and Requiring Authentication

For security reasons, it is recommended to disable guest access and configure settings to allow access only by specified users. Follow these steps to modify the settings:

  1. Open a terminal and enter the following command to edit the Samba configuration file (smb.conf):
sudo nano /etc/samba/smb.conf
  1. Add or modify the following settings in the section for the shared folder in question (for example, the [share name] section):
[share name]
path = /home/mamu/Documents
read only = no
guest ok = no
valid users = mamu
  • guest ok = no: Disables guest user access.
  • valid users = mamu: Allows access only to the mamu user. Access will be denied to other users attempting to access the share.
  1. Save the settings and close the file.
  2. Enter the following command to restart the Samba service and apply the settings:
sudo systemctl restart smbd

With this configuration, only the specified user (in this case, mamu) will be able to access the share. When accessing from Windows, you should be able to log in using this username and password.

Important Note

If the username and password on Windows and Ubuntu match, Windows may automatically attempt to connect using the same credentials, and the authentication prompt may not be displayed. This is a convenient feature of Windows, but in some cases, the intended authentication prompt may not appear, making it difficult to log in manually.

In such cases, removing the credentials for the Ubuntu machine in question from Windows Credential Manager will allow manual login.

Adding this content to the article will enable readers to learn how to disable guest access and configure settings to allow access only to specific users. They will also gain an understanding of the important point to keep in mind when the username and password match between Windows and Ubuntu.

Accessing Windows and Other Shared Folders from Ubuntu

There are two ways to access Windows and other shared folders from the Ubuntu desktop: using the file manager or using commands.

  1. Accessing via File Manager (GUI)
  • Open the file manager (usually called “Files” or “Nautilus”).
  • The file managers in Ubuntu and other Linux distributions serve the same role as Windows Explorer. They allow you to browse and manage files and folders, as well as access network shared folders.
  • Ubuntu’s default file manager is called “Nautilus” and can be used with a similar interface to Explorer. It has features like selecting folders in the sidebar and connecting to network shared folders from “Other Locations”.
  • Select “Other Locations” in the sidebar.
  • In the “Connect to Server” field at the bottom of the screen, enter the following: smb://<IP address or hostname of the share>/
    Example: smb://192.168.1.10/
  • Click the Connect button and enter the username and password if prompted. You should now be able to access the shared folder through the file manager.
  1. Accessing via Command Line (Terminal) To access a shared folder from the terminal, use the smbclient command. Follow these steps to try it out:
  • Install smbclient. Note: smbclient may not be installed by default. Use the following command to install it:
    sudo apt update
    sudo apt install smbclient
  • Connect to the shared folder:
    smbclient //IP address of the share/share name -U username
    Example: smbclient //192.168.1.10/documents -U username
    Note: If you don't specify the share name, nothing will happen.
  • When prompted, enter the password. You should now be able to access the shared folder. Inside smbclient, you can use FTP-like commands to list files (ls), retrieve files (get filename), send files (put filename), and more. If the connection is successful, you will see a prompt like this:
smb: \>

Retrieving Files and Save Location

When using the get filename command in smbclient, the file will be saved in the current working directory. The working directory is the current directory in the terminal where you executed the smbclient command.

For example, if you run smbclient in the /home/mamu directory, files retrieved with the get filename command will be saved in /home/mamu.

To check the current working directory, use the pwd command:

pwd

You can also change the local save location using the lcd command before running get filename:

lcd /home/mamu/save_directory
get filename

This way, the file will be saved in the specified directory.

Retrieving Files with Spaces in the Name

When specifying a file name containing spaces with the get command, entering the file name as-is resulted in the following error:

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 the file name contains spaces, and smbclient cannot correctly recognize the file name.

To resolve the error, specify the file name using one of the following methods:

  • Enclose the entire file name in double quotes (" ") or single quotes (' ').
get "2024-10-30 17-22-24.mkv"
  • Escape the spaces using a backslash (\).
get 2024-10-30\ 17-22-24.mkv

Using these methods, smbclient will recognize the entire file name as a single file and download it correctly.

smb: \> get "2024-10-30 17-22-24.mkv"
getting file \2024-10-30 17-22-24.mkv of size 3556859 as 2024-10-30 17-22-24.mkv (6878.2 KiloBytes/sec) (average 6878.2 KiloBytes/sec)

Displaying the Ubuntu Machine in the Windows Network List

Currently, although the Ubuntu machine is not displayed in the Windows network list, access is still possible. However, displaying the Ubuntu machine in the list will allow for more seamless access. If Windows PCs are not displayed either, it may be necessary to check the network discovery and sharing settings.

To display the Ubuntu PC, we’ll use wsdd2 (Web Services Dynamic Discovery). Follow these steps to install wsdd2:

sudo apt install wsdd2

After installing wsdd2, the Ubuntu machine with Samba configured should appear in the Windows network list.

Note: I checked with the firewall disabled immediately after installing wsdd2. If the firewall is enabled, additional settings may be required.

Also, “SMB 1.0/CIFS File Sharing Support” needs to be enabled.

Checking and Configuring the Firewall

When sharing files on Ubuntu, if the firewall is not properly configured, access from Windows may not be possible. Here, we’ll explain how to check the firewall and the necessary settings.

Checking the Ports Used by wsdd2

wsdd2 uses the following ports for service discovery:

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

When configuring the firewall, ensure that these ports are open.

Summary

When setting up file sharing on the Ubuntu 24.04 desktop, I confirmed that the following steps can be used to configure it without issues. A notable point is that installing Samba or editing the configuration file is unnecessary.

  1. Install nautilus-share
sudo apt install nautilus-share
  1. After installation, log out (reboot not required)
  2. User settings (set to the current user; also possible for new users)
sudo usermod -a -G sambashare $USER
sudo smbpasswd -a $USER
  1. Restart the Samba service
sudo systemctl restart smbd
  1. Set permissions
sudo chown root:sambashare /var/lib/samba/usershares
sudo chmod 1770 /var/lib/samba/usershares
  1. Restart Nautilus
nautilus -q

Restarting is necessary; logging out is not sufficient.

After executing these steps, file sharing can be configured via GUI using “Sharing Options”. There was no need to change file permissions.

This article has provided detailed explanations of various methods and solutions for setting up file sharing on Ubuntu 24.04. However, upon actual verification, it was found that installing Samba or editing the configuration file is unnecessary, and file sharing functions sufficiently with the steps mentioned above.

I recommend that readers first try this simplified procedure, and if problems occur, refer to the detailed explanations provided in the article.

File sharing on Linux may have different setup methods depending on the distribution and version. I will continue to provide the most beneficial information to readers while conducting verifications in actual environments.

If you like this article, please
Follow !

Please share if you like it!
table of contents