How to Share Files Between Linux and Windows? [2 Cases]

A common way to communicate between operating systems such as Windows and Linux is to share files. You can accomplish this through various processes such as  Samba, SFTP or FTP, SSH, cloud storage, or a portable device. Although this may sound pretty tedious but with the appropriate technique, you can master it in no time. In this article, I will demonstrate how to share files effortlessly between Linux and Windows in two simple methods.

Key Takeaways

  • Learning how to share files over a network using Samba.
  • Knowing how to share files using a virtual machine without the need for any network.
  • Learning about sharing requirements and deciding on a suitable method.

Requirements

Process Flow Chart

Distro Used Throughout the Tutorial: Ubuntu 22.04.02 LTSProcess to Share Files between Linux and Windows

Watch 2 Cases to Share Files Between Linux and Windows

2 Cases to Share Files Between Linux and Windows

Let me introduce you to two simple and easy scenarios for file sharing between Linux and Windows, even if you are a beginner in Linux. These methods will provide you access from either operating system and you won’t need to worry about file sizes or formats.

You can read our Comparative Analysis of Cases to distinguish between these two cases and pick the best one according to your need.

Case 01: Share Files Between Linux and Windows Using Samba

Samba is a free and open-source software suite that allows users to share files, folders, and printers between different operating systems running on a single network. It is a widely popular method due to its simplicity, stability, and compatibility with both Linux and Windows. Moreover, it offers seamless sharing of files with the added benefit of being able to configure user access and permissions.

Step 1: Installing Samba on Ubuntu

First, you need to install Samba on the Linux operating system. Here, I am using Ubuntu as my Linux distribution where I will be installing this software.

Steps to Follow >

➊ Open your Ubuntu terminal.

➋ Type the following command to install Samba and press ENTER.

sudo apt-get install samba

EXPLANATION
  • sudo: Permits a user with administrative privileges to execute commands.
  • apt-get install: Specifies that the install task needs to be performed.
  • samba: Name of an open-source and free software package.

Install Samba in Linux➌ Confirm that the installation was complete and check its location in the system with

whereis samba

EXPLANATION
  • whereis: Look for the location of the installed package.
  • samba: Name of the package.

Find the location of installed Samba package in Linux system.➍ Type the following command to assign a password for the Samba service.
sudo smbpasswd  -a  ayesha

EXPLANATION
  • sudo: Permits a user with administrative privileges to execute commands.
  • smbpasswd: Sets password for Samba users.
  • -a: Allows the command to add a new Samba user.
  • ayesha: User name.

Set password to Samba to add a user for file sharingIn the image above, the command asked for my password in order to add user ayesha.

Step 2: Configure Samba on Ubuntu

After installing Samba, it is important to configure it so that it is functional for both operating systems. This step involves creating a directory as the shared folder and then making changes to the Samba configuration file.

Steps to Follow >

➊ Open Ubuntu terminal.

➋ Create a folder with the mkdir command. Here, I have created the folder, Shared_Folder in Desktop for easy access.

mkdir /home/ayesha/Desktop/Shared_Folder

EXPLANATION
  • mkdir: Creates a new directory or folder
  • /home/ayesha/Desktop/Shared_Folder: Absolute path of the location of the folder.

➌ Next, you have to configure the Samba service and make it suitable to share files with Windows. For that, run the given command in the terminal.

sudo nano  /etc/samba/smb.conf

EXPLANATION
  • sudo: Permits a user with administrative privileges to execute commands.
  • nano: Text editor
  • /etc/samba/smb.conf: Configuration file of Samba to customize settings such as user authentication, shares, and security.
  • conf: Configuration file. smb stands for Sever Message Block Configuration.

➍ Provide the password of the currently logged-in user.Command to configure Samba settings in a text file to share files. After providing the password it will open up the text editor where you can alter the configuration settings of the shared folder.

➎ Once the text editor opens, write these lines at the end of the file.

[Shared_Folder]
   
        path = /home/ayesha/Desktop/Shared_Folder
        available = yes
        valid users = ayesha
        read only = no
        writeable=yes
        browseable=yes
        public = yes
EXPLANATION
  • Shared_Folder: Name of the folder whose contents you want to share.
  • path: Absolute path of the folder you want to share.
  • available: Specifies whether the file is available for sharing or not.
  • valid users: User name.
  • read-only: Specifies whether the file is available for reading or not.
  • writeable: Specifies whether the folder can be written to or not.
  • browseable: Specifies whether the shared file is visible while browsing the network or not.
  • public: Specifies whether the shared file is accessible to all users or not.

➏ Finally, press CTRL+O and CTRL+X to save the changes and exit the editor respectively.

Write details of the shared folder in Samba configuration settings needed to share files

Remember to write the folder name, its path, and user name carefully. I chose Shared_Folder as my folder name and its absolute path in the system is included in the mentioned code. Besides, ayesha is the user name in my Linux system.

Read More: How to Configure NFS Server in Linux? [5 Steps]

Step 3: Check Samba Status on Ubuntu

You have to make sure that Samba is active otherwise the shared folder will not be accessible. You can ensure this by checking its status.

Steps to Follow >

➊ Open your Ubuntu terminal again.

➋ Run the following command to restart Samba in Linux.

sudo service smbd restart
EXPLANATION
  • sudo: Permits a user with administrative privileges to execute commands.
  • service: Controls services in the Linux system.
  • smbd: Samba daemon which provides file-sharing services to Windows clients.
  • restart: Stop running the service and start again.

➌ Enter the password of the currently logged-in user.Restart Samba service in order to share files.➍ Now make sure that the smbd daemon is activated and operational.

systemctl status smbd
EXPLANATION
  • systemctl: Manages system services, along with starting, stopping, and checking the status of services.
  • status: Displays the current status of a service.
  • smbd: Samba daemon which provides file-sharing services to Windows clients.

Check Samba status to ensure it is active to share files.The image above indicates that Samba is active or running. You can access shared folders from the other operating system only after Samba is activated.

Step 4: Create a File in Linux and Access It From Windows

To confirm if files are accessible, I will proceed to create a file in the Shared_Folder and attempt to control it from Windows.

Steps to Follow >

➊ Open your Ubuntu terminal.

➋ Type the following command in the Ubuntu terminal to get your Linux IP address.

hostname  -I
EXPLANATION
  • hostname -I: Displays the IP address associated with the hostname.
Find the the IP address of Linux systemThe terminal shows that the IP address of my Linux system is 192.168.153.128. This will come in handy in the next step.

➌ Now go to Windows and open “This PC”.

➍ Click on the address bar and type the IP address and name of the folder which you created in Linux.

\\192.168.153.128\Shared_Folder
EXPLANATION
  • 168.153.128: IP address of my Linux system.
  • Shared_Folder: Name of the folder you have created in Linux to share files.

Enter IP address of Linux system and name of Shared Folder to share files.➎ After this a dialogue box will appear on the screen asking for your Linux username and password. Make sure to enter them carefully and press OK.Enter network credentials to share with Windows. You can see in the above image that the username and password are entered here. But don’t worry if “Access is denied.” shows up. It will appear until you put in your network credentials.

Shared_Folder will open instantaneously when you hit OK. The folder will open as an empty folder in both Linux and Windows.No files seen in shared folder in Windows.The above image depicts that Shared_Folder in Windows is accessible.No files seen in shared folder in Linux.The above image depicts that Shared_Folder in the Linux system is also accessible.

➐ To understand that Windows can access the files in the folder, I have saved an image in Shared_Folder in the Linux system.An image file saved in Linux.➑ Now check Shared_Folder in Windows.Image file shared with Windows.You can now view the photo from Windows and have full control over it.

Step 5: Create a File in Windows and Access It From Linux

The file was accessible from Windows. But can you manage files created in Windows from Linux? Let’s find out.

Steps to Follow >

➊ First, create a Word file in Shared_Folder from Windows.Word file created in Windows.➋ Go to Linux and open Shared_Folder there.Word file shared in Linux. You can see in the above image that the file is visible and you can similarly have full control over it from Linux.

Read More: How to Share Files between Linux and Windows Dual Boot [3 Methods]

Case 02: Share Files With a Virtual Machine Between Windows and Linux

Multiple operating systems can run on a single physical computer with the help of VMware Workstation which is a virtualization software. This method is deemed advantageous if you wish to save time and effort in contrast to the laborious and time-consuming approach of file transfer through a network share. In this part, I will show you how you can share your files with VMware.

Step 1: Enable Shared Folder in Virtual Machine (VMware)

It is mandatory to enable the shared folder option in VM settings. This will ultimately grant anyone permission to have full access to files from either operating system.

Steps to Follow >

➊ At first power on your VMware Virtual Machine.

➋ Go to VM > Settings.Open VM > Settings to share files in virtual machine.➌ Next go to Options > Shared Folder. Click on Always enabled. Then hit on Add.Enable and add folder to share files.➍ Then browse the folder you want to share. I have chosen the folder Ayesha in this regard and its location and name of the folder appeared on the Host path and Name dialogue boxes. Afterward, click on Next.Browse location of folder to share files.➎ Now click on Enable this share and then press Finish.Enable sharing of files.➏ Make sure that your desired folder is added in the Folders option. Click on OK when you have completed the steps above.

Ensure folder to share files is added.You can see in the image shown above that folder Ayesha along with its location on my PC has been added to Folders box. It is now available for sharing files.

Step 2: Create a Directory to Mount Shared Folder

Now mount the shared folder, Ayesha in the existing /mnt/ directory as it is the standard folder for temporarily mounting files or devices. Moreover, /mnt/ does not interfere with any existing directory in the system. The mounted folder is now easily recognizable in the Linux system.

Steps to Follow >

➊ Open your Ubuntu terminal.

➋ Type the following command to make a folder named hgfs using mkdir command in the mnt directory.

sudo mkdir /mnt/hgfs
EXPLANATION
  • sudo: Permits a user with administrative privileges to execute commands.
  • mkdir: Creates a new directory or folder in the system.
  • /mnt: Directory in Linux system that is used as a mount point for temporary files.
  • /mnt/hgfs: Absolute path of the location of the newly created directory, hgfs.

➌ Now execute the following command to finally mount the shared folder, Ayesha.

sudo vmhgfs-fuse .host:/ /mnt/hgfs/ -o allow_other -o uid=1000
EXPLANATION
  • sudo: Permits a user with administrative privileges to execute commands.
  • vmhgfs-fuse: Command that mounts VMware shared folders in the Linux file system.
  • .host:/: This specifies the name of the VMware shared folder that you want to mount. The dot (.) at the beginning specifies the default mount point.
  • /mnt/hgfs: Absolute path of the location of the newly created directory, hgfs. This indicates where you want to mount your shared folder.
  • -o: Specifies the options to use when mounting a folder.
  • allow_other: The first option allows other users on the system to access the mounted shared folder.
  • uid=1000: This option sets the user ID (UID) of the mounted shared folder to 1000. 1000 is the default UID. UID indicates which user owns the files of the mounted directory.

➍ Afterwards, type the following command to ensure that the shared folder is available in the terminal.

vmware-hgfsclient
EXPLANATION
  • vmware-hgfsclient: Displays list of available shared folders.
Check availability of shared folder.As you can see, this command views the shared folder Ayesha on the terminal.

➎ Now implement the commands below one by one to navigate to the folder Ayesha using cd command and list its contents with ls command.

cd /mnt/hgfs/Ayesha
ls
EXPLANATION
  • cd: Changes the current working directory helping you to navigate through the file system by specifying the path of the directory you want to change to.
  • /mnt/hgfs/Ayesha: Absolute path of the folder Ayesha in mnt directory.
  • ls: Lists the contents of a directory.

Navigate to folder to share files.The image shows that at first, folder Ayesha is stored in hgfs sub-directory within mnt directory. When listing this folder, it shows nothing since it is empty at the moment.

Step 3: Locating the Shared Folder on Linux

It is important for you to understand the accessibility of this folder. To do so you need to find its location at first.

Steps to Follow >

➊ Now in the Files in Ubuntu, go to Files > Other Locations > Computer.Locate the shared folder in Linux. ➋ Then click on the folder named “mnt”.Navigate to mnt directory to avail shared folder.➌ Then browse through hgfsAyesha.Shared folder is empty in Linux In the above image, you can see that the folder Ayesha is empty at this point.

Step 4: Create a File in Linux and Access It From Windows

Let’s create a file in the folder Ayesha and access it from Windows.

Steps to Follow >

Navigate to the shared folder in my case which is Ayesha and type the following commands to create a text file.

touch file.txt
ls
EXPLANATION
  • touch file.txt: Creates an empty file named file.txt
  • ls: Lists the contents of a directory.
Create a file in Linux terminal to share with Windows.➋ Now when you open the folder Ayesha from Files in Linux, you will see the text file named file.txt.Vie the text file, to share, in Linux.➌ Open the folder in Windows.File shared with Windows.In the above image, you can see that I have successfully accessed the shared file from Windows.

Step 5: Create a File in Windows and Access It From Linux

Now I will save an image in the folder Ayesha in Windows and try to access it from Linux.

Steps to Follow >

➊ First, save a file in the specific shared folder in Windows. In my case, I will save a file named “Photo.jpeg” on my shared folder named “Ayesha” in Windows.Image file saved in Windows to share.➋ After that type the following command in the Ubuntu terminal after navigating to the shared folder.

ls
EXPLANATION
  • ls: Lists the contents of a directory.
View image file from Linux terminal.The above image displays the contents, file.txt, and Photo.jpeg in the folder Ayesha.

➌ To check it from the graphical user interface, navigate to your shared folder in Linux which is in my case Files>Other Locations>Computer>mnt>hgfs>Ayesha.

The shared file is accessed from Linux.

In the above image, you can see that I can successfully access the shared image on my Linux Virtual Machine.

Comparative Analysis of Cases

Ather going through the above-mentioned cases you may be confused in choosing the suitable process. I have shown a comparison of both scenarios to demonstrate the advantages and disadvantages. Hopefully, this will help to understand the criteria for deciding the best method.

Cases Pros Cons
Case 1
  • Reliable and convenient way.
  • Flexible supporting a wide range of file systems.
  • Provides security through user authentication and password encryption.
  • Complex to install & configure
  • Requires prior knowledge of command line interface.
Case 2  
  • Time-saving.
  • Compatible with different operating systems.

 

  • Presents security issues for sensitive or confidential files.

To simplify, Case 1 is preferable when different operating systems are used and file sharing is a common requirement. On the other hand, sharing through Case 2  is feasible when you’re working with virtualized environments.

Conclusion

If you are confused about file sharing or find this process complicated, try the methods mentioned in this article. The file-sharing process has been simplified here so that anyone, regardless of their expertise in Linux, can undergo this experience smoothly and with no hassle. However, your need to share over a network or a virtual machine decides the scenario you are in and therefore you can transfer files based on your preference. Moreover, keep in mind that file sharing can pose security risks. Therefore, I recommend you to have a regular backup for your files and folders.

People Also Ask

What is the fastest way to share files between Linux and Windows?

To share files fast between Linux and Windows, you can rely on FTP. However, SFTP or SCP can provide fast and secure data sharing.

What is the difference between SMB and NFS?

SMB (Server Message Block), a protocol developed by Microsoft, is designed for Windows to share files and printers over a network. It is supported by non-Window operating systems, such as Linux and macOS. On the contrary, NFS (Network File Systems), developed by Sun Microsystems, is used mainly by Linux and allows faster file sharing on remote or local systems.

Which one is better SMB or FTP?

SMB is considered better than FTP since it is faster and more efficient in file sharing. On the other hand, FTP is platform-independent and supported by most web browsers. However, FTP poses security threats as FTP transfers are not protected by encryption.

What security concerns should I consider when sharing files between Linux and Windows?

Some key security concerns that you should keep in mind are authentication to restrict unauthorized access, encryption to protect the confidentiality of files, configuring firewalls, file types, and the latest security updates to alleviate potential security vulnerabilities.

How do I troubleshoot common issues when sharing files between Linux and Windows?

Some common troubleshooting issues in file sharing involve network connectivity, file permission, configuration, firewall, name resolution, and protocol settings. Addressing these issues and resolving them can ensure seamless file sharing.

What are some alternative ways to share files between Linux and Windows besides Samba?

Some alternative ways besides Samba include SSH, FTP or SFTP, NFS, web-based services such as Google Drive, Dropbox, or OneDrive and portable devices.

What is the best way to share files between Linux and Windows?

The process of file sharing depends on user requirements and preferences. Hence it is difficult to name one best way. However, Samba is considered the popular and reliable option as it offers seamless and more protected file transfer. Using cloud storage devices such as Google Drive, OneDrive or Dropbox can ensure file sharing across different operating systems.

Related Articles 

Rate this post
LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now
icon linux
Ayesha Tun Nashrah

Hello! I am Ayesha Tun Nashrah, currently working as a Linux Content Developer Executive for LinuxSimply, SOFTEKO. Completing my graduation in engineering, I aim to collaborate my technical knowledge and creative writing skills to create engaging content for Linux. My goal is to contribute to the Linux community by writing tutorials, articles, and guides for novice and Linux experts. Besides, writing about Linux articles, you will find me immersed in books and enjoying music. Read Full Bio

2 thoughts on “How to Share Files Between Linux and Windows? [2 Cases]”

    • Thank you for sharing your thought. I hope this article makes file sharing between Linux and Windows easy for you.

      Reply

Leave a Comment