- How to share files between a Linux and Windows computer
- Create a shared folder on Windows
- Access a Windows shared folder from Linux, using Konqueror
- Access a Windows shared folder from Linux, using Nautilus
- Access a Windows shared folder from Linux, using the command line
- How to Share Files and Folders Between Linux and Windows
- Samba makes it easier than you might think
- What Is Samba?
- Installing Samba
- Configuring Samba
- Adding Users
- Ready for Access
- How to Share Files Between Windows and Linux
- Sharing files between Windows and Linux
- How to share and transfer files between Linux and Windows
- File Sharing between Linux and Windows Systems
- Over the Network
- Method 1: Transfer Files Between Ubuntu And Windows Via SSH
- Method 2: Transfer Files Via Samba
- Method 3: Shared Network Folders
- Transferring files between Windows and Linux on the same machine
- Why it isn’t easy
- A simple solution
- Create a SharedPartition
- Configure Auto-Mount on Linux
- Configure your Special Folders (Linux)
- Configure your Special Folders (Windows)
How to share files between a Linux and Windows computer
The easiest and most reliable way to share files between a Linux and Windows computer on the same local area network is to use the Samba file sharing protocol. All modern versions of Windows come with Samba installed, and Samba is installed by default on most distributions of Linux.
Create a shared folder on Windows
First, create a shared folder on your Windows machine.
- Open the Control Panel.
- Go to Network and Sharing Options.
- Go to Change Advanced Sharing Settings.
- Select Turn on Network Discovery and Turn on File and Print Sharing.
Now, create a new folder to share or choose an existing folder that you’d like to share.
- Right-click the folder and select Properties.
- Go to the Sharing tab.
- Above the Share button is the network name of the share you are creating. It should look like \\YOURCOMPUTERNAME\Users\YourUserName\ShareFolderName. Make a note of this network name to use later on your Linux machine.
- Click Share.
Access a Windows shared folder from Linux, using Konqueror
Many Linux distributions use the KDE desktop environment and the Konqueror file manager/browser. If this is what you are using, you can follow these steps to access your Windows shared folder:
- Click the K menu icon.
- Select Internet ->Konqueror.
- In the Konqueror window that opens, click the Network Folders link, or type remote:/ in the address bar and press Enter .
- Click the Samba Shares icon.
- Click the icon of your Windows Home workgroup.
- Click the Workgroup icon.
- Click the icon for your computer.
- When prompted, enter the username and password for the Windows account that created the share.
- Click OK.
Access a Windows shared folder from Linux, using Nautilus
Many Linux distributions, especially those that use the GNOME desktop environment, use the Nautilus file manager. If this is what you’re using, you can follow these steps to access your Windows shared folder:
- Open Nautilus.
- From the File menu, select Connect to Server.
- In the Service type drop-down box, select Windows share.
- In the Server field, enter the name of your computer.
- Click Connect.
Alternatively, in the Nautilus address bar, you can type smb://ComputerName/ShareName and press Enter . For instance, when you created your Windows Share, if the share name was listed as:
Type smb://YOURCOMPUTERNAME/Users/YourUserName/ShareFolderName and press Enter . Note the smb: at the beginning; in Linux, use forward slashes instead of backslashes.
Access a Windows shared folder from Linux, using the command line
You can also access your Windows share from the Linux command line using the smbclient program.
- Open a terminal.
- Type smbclient at the command prompt.
- If you receive a «Usage:» message, this means smbclient is installed, and you can skip to the next step. If the command is not found, however, you need to install smbclient. Follow these steps to install it.
How to Share Files and Folders Between Linux and Windows
Samba makes it easier than you might think
If your Linux machine is on a network, chances are you might want to share a directory (folder) or two to other users. Some Linux desktop environments (such as GNOME) make this incredibly simple. Some distributions and/or desktop environments, however, (such as Elementary OS) don’t offer a simple GUI for the sharing of folders.
Should you happen to be using a desktop environment that doesn’t make the process of sharing directories to your network a simple point-and-click affair, you’re not out of luck. Thanks to Samba (the underlying technology that makes this happen), you can still share those directories. It’s a bit tricker, but it’s not terribly hard.
What Is Samba?
Samba is an open-source software that enables Linux-based systems to communicate with Windows and macOS systems via the Common Internet File System (CIFS). Samba gets its name from the Server Message Block (SMB) protocol, which is at the heart of CIFS. Without Samba, directories on Linux wouldn’t be visible to Windows or macOS machines on your network.
For the purpose of this demonstration, we tested using Elementary OS 5 (Loki), which is based on Ubuntu Linux (so the process will be the same for any Ubuntu-based distribution) and Samba version 4.7.6.
Installing Samba
Chances are, you’re going to have to install Samba, as it is not included on most Linux desktop distributions. To install Samba, follow these steps:
Open a terminal window from your desktop menu.
Issue the command
sudo apt install samba samba-common -y
When prompted, type your user password.
Allow the installation to complete.
That’s all there is to the installation.
Configuring Samba
This is where things do get a bit challenging. What you must do is manually configure what are called Shares, with the Samba configuration file. In simple terms, a share is a directory you want to share with others on your network. We’ll create a very basic share.
The first thing to do is back up the original Samba configuration file. To do this, open a terminal window and issue the command
sudo cp -pf /etc/samba/smb.conf /etc/samba/smb.conf.bak
With the original file backed up, it’s now safe to edit the original. Issue the command
sudo nano /etc/samba/smb.conf
and scroll to the very bottom of that file. What we’re going to do is add a new share for the Public folder, found in your user home directory. Let’s say your username is jack. The full path to that Public folder would be /home/jack/Public. That’s important to know.
This new share will look like this:
[Public]
path = /home/jack/Public
browseable = yes
writeable = yes
read only = no
Save and close that file by typing Ctrl + x. Finally, restart Samba with the command
Adding Users
Now we have to add our Linux users to Samba. Why? Because although the Linux system recognizes the users, Samba does not. One thing to understand is that anyone wanting to have access to those shared directories will need to have an account on your machine. You can create anonymous access to those shared folders, but it lacks security (and we want to keep our machines as secure as possible).
Fortunately, there are only two simple commands to run. We’ll stick with our sample user, jack. The first command adds the user to Samba (requiring you type and verify a new password). This command is:
sudo smbpasswd -a jack
You might first be prompted for your users’ sudo password. Type that and then, when prompted, type and verify a new Samba password for the Samba user.
The second command enables the user for Samba. This command is:
sudo smbpasswd -e jack
Ready for Access
That’s it. The new user is added and will then be able to access the shares. If you go to another machine on your network, you should be able to access that share from your desktop’s file manager (with the username and password you configured using the smbpasswd command). How you access the share will depend upon the operating system and file manager used on the other machines.
How to Share Files Between Windows and Linux
File sharing is the action of sending a file or more from one computer to another. In theory, it’s a simple thing. The process is quite simple and straightforward if both of the computers are running the same operating system. When it’s different, things get a bit complicated.
In this guide, check out how to share files between Windows and Linux.
Sharing files between Windows and Linux
There are multiple ways to configure both Windows and Linux to share files. However, in the case of this guide, I’ll be mostly showcasing how to configure Linux for file sharing. For Windows-specific configuration, I’ll be showcasing only the necessary ones.
Let’s get started!
Share files using portable storage devices
This is one of the most common and traditional ways of sharing files between two computers. Generally, it involves portable storage media. Got a USB flash drive? A portable HDD/SSD? Just plug it into the source computer, copy the data to the portable storage, and share it with your target computer.
In certain scenarios where the data is too big to be shared over the network/internet, this is the best solution. In a professional workspace where terabytes of data need to be shared and stored, there are portable RAID arrays to do the job.
While it’s simple and effective, there are a couple of things to keep in mind.
- Storage capacity: Data bigger than the capacity can’t be stored on portable storage. If that’s the case, then you may split the file into smaller pieces using file splitting software. You may have to move the data through the portable storage several times.
- File size: If the file size is quite small, and there’s lots of them, the transfer rate is going to be slow. On the other hand, if the file size is ridiculously large, then it’s also going to be slow.
- Filesystem: Linux and Windows come with their own filesystem. While filesystems like FAT (fat16, fat32, etc.) or NTFS are accessible from both Windows and Linux, the Linux-specific filesystems (ext3, ext4, xfs, btrfs, etc.) aren’t.
Share files over cloud storage
Cloud storage is the standard way of file sharing in this internet era. Files can be uploaded and downloaded on any device with a modern web browser. However, there are a couple of different points to remember if you wish to choose this path.
- Storage capacity: In the case of online cloud storage, storage capacity is a big concern. Popular cloud storages offer a limited amount of cloud storage for free. If your file is larger than that, you may have to buy additional cloud storage space. You can also split the big file into multiple small ones.
- Bandwidth: This is the second biggest concern when it comes to cloud storage. If the internet connection you’re using is slow, then the file upload/download time will take quite a while. If you’re using a metered connection, it can cost you a lot.
Some of the popular online cloud storage include Google Drive, Dropbox, OneDrive, pCloud, Box, etc. Almost all of them offer a reasonable amount of cloud storage for free.
Share files using network folders
If both computers are on the same network, it’s possible to take advantage of it. In this method, certain folders of the source machine will be available to other machines.
Configure Linux
To enjoy this feature, you have to configure the systems first. In the case of Linux, Samba is the perfect solution. Samba is the standard suite of programs for UNIX/Linux operating systems for standard Windows interoperability. Check out Samba.
Samba is popular software that you can grab from the official package repos of your distro. To install Samba, run the command according to your distro.
How to share and transfer files between Linux and Windows
File sharing between Windows and Linux connected over a local network can be done in several ways. This tutorial mentions the most common methods that use simple techniques.
P reviously we have shown you how to remotely connect to your Linux machine from a Windows one (Click here). Now, what if you need to transfer some files between your Windows and Linux systems?
Well, a USB drive comes handy for simple data transfers. For a large number of files at different times, you need another efficient method. Transferring your data between Linux and Windows using your local network is the recommended option. With an easy and quick one time setup, you can share your files between various machines.
File Sharing between Linux and Windows Systems
In this tutorial, we shall walk you through sharing your files between Ubuntu and Windows machines over a local network, and we shall also show you how to transfer files between Windows and Linux on the same PC.
Over the Network
Transferring files between Ubuntu and Windows can be done in many ways, but in this tutorial, we are going to discuss the following popular methods:
- Transfer files between Ubuntu and Windows via the SSH.
- Transfer files between Ubuntu and Windows using Samba.
- Transfer files between Ubuntu and Windows using Shared Network Folders.
Method 1: Transfer Files Between Ubuntu And Windows Via SSH
In this method, you need to install and enable SSH service on Ubuntu. Also, we need an SSH client application on Windows. In this tutorial, we shall be using Putty. Next, we are going to use the command line to share your files across the network.
Step 1. Install the SSH package on Ubuntu using the next command.
Install The Open SSH Package On Ubuntu
Step 2. After installation finishes successfully, you can check the SSH service status using the following command.
The output of the command should look like the below screenshot:
Check The SSH Service Status
If the service is not running, you can use the following command to start it:
Also, to enable the SSH service to start every time your system starts up, you can use the following command:
Step 3. Install the net-tools package.
Install net-tools package
Step 4. Execute the next command to get your Ubuntu machine IP.
Ubuntu Machine IP
Step 5. From your Windows machine, we need an SSH client (which is Putty) and a PSCP. PSCP is considered a secure copy tool that is used alongside with Putty to transfer files securely over a network.
You can download both (Putty and PSCP) from the Putty official website. (Click here.) Kindly note that Putty will need to be installed while the PSCP won’t. You have to put the PSCP.exe in the “C:\” drive to be used, as you should see shortly.
Step 6. Now open the file explorer and use the next command to start transferring your files from your Windows machine to Ubuntu.
Copy File From Windows To Ubuntu Via SSH
Step 7. Next, you should enter your Ubuntu password.
Enter Your Ubuntu Password
Step 8. After entering the password successfully, the command shall copy the text file from your Windows machine to your Ubuntu home. You can check your home directory now, and you should find the file there.
Check The Copied File
Step 9. Now in case you need to transfer your files from Ubuntu machine to Windows, open the file explorer from your Windows machine and use the next command. Be careful, and do not forget the dot at the end of the command.
Copy File From Ubuntu To Windows Via SSH
By executing the previous command, you should enter the password of your Ubuntu machine. Next, the file gets transferred from Ubuntu to the Windows current directory.
File Copied Successfully
Method 2: Transfer Files Via Samba
In this method, we are going to install the Samba package on Ubuntu. Moreover, use the Windows run application to connect to the Ubuntu shared directories.
Step 1. Install the Samba package on Ubuntu using the following command.
Install Samba Package On Ubuntu
Step 2. You can set a password to the samba share as follows.
Add A User For Samba Share
where hendadel is an Ubuntu user that you shall use while accessing the Ubuntu shared directory.
Step 3. Let’s create a directory that is used for sharing your files.
Create Directory For The Shared Data
Step 4. Using your favorite text editor, open the samba configuration file.
Open Samba Configuration File
Step 5. Add the next lines at the end of the samba configuration file.
The samba configuration file should like the below:
Edit Samba Configuration File
Save and exit the samba configuration file.
Step 6. Restart the samba service using the following command:
Restart Samba Service
Step 7. From the Windows machine, open the run application from the Start menu and enter the Ubuntu machine IP with the shared directory name as follows.
Remote Access To Your Ubuntu
Press the OK button to continue.
Step 8. A Windows Security message will appear, you should have to enter your samba username and password. Then press the OK button to continue.
Authentication Required
Step 9. Now you should have access to your Ubuntu shared directory, and you can transfer files.
Welcome To Your Ubuntu Shared Directory
Method 3: Shared Network Folders
This is the easiest method among all. In this method, we share any folder from the Windows machine to be visible in the Ubuntu machine.
Step 1. From the Windows machine, right-click on the network connections icon in the right bottom of the taskbar.
Right Click On Network Connections
Step 2. Choose the “Open Network & Internet Settings.”
Open Network and Internet Settings.
Step 3. Next, choose “Sharing Options.”
Open Sharing Options
Step 4. Now from your current network profile, choose the following options:
- Turn on network discovery.
- Turn on file and printer sharing.
Choose Options And Save Changes
Don’t forget to save your changes.
Step 5. Now open your file explorer and go to the directory that you need to share. Right-click on the folder then select Properties.
Open Folder Properties
Step 6. After opening the folder properties, let’s choose the Sharing tab. Also, select the Advanced Sharing button.
Open Advanced Sharing
Step 7. Mark “Share this folder” box.
Check The Share This Folder
In case you need to set permissions on the shared folder like (Read, Write), you can select the permissions button and set your permissions.
Set Sharing Permissions
Press the OK button to continue.
Step 8. Now from the Ubuntu machine, open the file browser.
From Your Ubuntu Open The File Browser
Step 9. From the left panel, choose “Other Locations.”
Open Other Locations
Step 10. In the bottom bar, enter your Windows machine IP and path to the shared folder as follows:
Connect To Windows Shared Folder
Then press the Connect button.
Step 11. An authentication message should appear. Enter your username and password. Press the Connect button to continue.
Enter Your Windows Machine Username And Password
Step 12. Next, you should be able to see your Windows shared folder. Now you can transfer files between the two machines.
Welcome To Your Windows Shared Folder
Transferring files between Windows and Linux on the same machine
Previously, we looked at how we can share files between a Linux PC and a Windows PC over a network. Some of the utilities used included SSH, Samba, and Shared Network Folders. Here, we will look at a relatively similar situation only that this time around, it will be on the same machine.
You might be wondering why can’t we copy files directly from a Linux partition to a Windows partition and Vice-versa? The simple answer is that; It will work for one but doesn’t work for the other. Let’s look at the reasons behind this.
Why it isn’t easy
The NTFS partition format used by Windows doesn’t support Linux file permissions. Therefore, we can’t consider installing Linux on an NTFS partition other than the Ext4. On the other hand, Windows cannot read the Linux file system even though Linux systems can read an NTFS partition. In most cases, the Linux partition is not listed in the “This PC” section on Windows in a dual boot. Therefore, you can copy a file from the Windows partition on Linux but not the vice-versa.
A simple solution
With the above information in mind, we need to find a way to favor both operating systems and wouldn’t pose any data corruption issues. For example, if you delete or alter any file in the Windows partition while accessing it with Linux, there is a high probability that Windows might raise some errors on boot.
Since Linux can’t run on an NTFS or FAT32 partition and Windows can’t read a Linux file system, we will need to configure a third partition that can be accessed by both operating systems. This third partition will contain commonly shared files between the two. Let’s call it the SharedPartition.
We can use other methods to share files, including external storage like USB or online storage like Google Drive and DropBox. However, these are tedious as one will require a reboot to switch from one OS to another while the other method is dependent on bandwidth.
Create a SharedPartition
Whether you have an SSD or Hard drive, we will require at least Four partitions:
- Linux Partition
- Windows Partition
- A SWAP space
- The SharedPartition (NTFS)
I believe you already have the first three. To create the SharedPartition, you can safely check our post on ‘Creating or resizing partitions in Linux.‘ Ensure you format it to NTFS. Additionally, you might need to understand the partition Table used on your Drives. That can be GPT or MBR. Our post on ‘Booting Linux or Windows from a USB drive‘ gives you a comprehensive guide on this. You will also understand the advantage of one over the other.
Up to here, we already have a SharedPartition that can be accessed by both Operating Systems. However, we might need to perform some configurations like Auto-mount on Linux and setting it as the default location for various files.
Configure Auto-Mount on Linux
We will need to execute several commands on the command-line. If you are just getting started with, don’t panic. Please copy and paste the commands as they are below. Our Linux distribution of choice in this post is Ubuntu 20.04 LTS.
Note: Remember to replace the name SharedPartition with the label of your new partition in any of the commands.
Step 1. Install the ntfs-3g driver, which enables Linux to read and write NTFS partitions.
Install NTFS-3g
Step 2. Create a directory where we will mount our new partition.
Create Mount directory
Step 3. Get the UUID (universally unique identifier) of the new SharedPartition with the command below.
You should see an output like this.
Know your UUID
Copy the UUID of the SharedPartition. The UUID identifies the partition in the /etc/fstab file.
Step 4. Since we will be editing the /etc/fstab file, create a backup with the command below.
Step 5. Execute the command below to edit /etc/fstab using the nano editor.
You should see a window like the one below. Add the following line at the end but remember to replace the UUID with yours.
Edit etc-fstab
After this step, reboot your PC. You should now see the SharedPartition mounted under the ‘Other Locations’ menu.
SharedPartition
Configure your Special Folders (Linux)
Special folders in Linux are those present on your Home directory. They include Desktop, Documents, Videos, etc. Execute the below command to edit their paths.
Special Folders
Now, we need to edit the paths to point to our SharedPartition mounted in /media/SharedPartition. For example, for Downloads, we will add the path “/media/SharedPartition/Downloads” and delete the “$HOME/Downloads” path. After applying the changes, you should have something similar to this:
Special Folders
Save your changes and close the Nano editor.
Configure your Special Folders (Windows)
Step 1. Open the File Explorer and type %userprofile% on the address bar. Hit enter.
User Profiles
Step 2. Select a folder, say Downloads, that you want to access in both operating systems. Right-click and select the properties option.
Step 3. On the pop-up window that opens, select the Location tab.
Location Tab
You will see the default path to your Downloads location.
Step 4. Click on the Move button. That will open a window where you will select your new Downloads path. Navigate to your SharedPartition and choose the Downloads folder already created in Linux. Click on the Select Folder button.
Select Destination Folder
Step 5. Click on the Apply button to set the changes.
You will see a pop-up window prompting you to move the content in the old folder to this new location. Click OK.
Apply Changes
That’s it. You can now proceed to do the same for the other Folders. Now, anything you save on these folders, e.g., Documents on Windows, will be accessible on Linux in the Documents directory.
Using another partition to share files between the two operating systems is the most reliable option since Windows cannot read the Linux file system without using third-party software. With this method, you don’t need to have duplicate files. Both operating systems can read and write on the same partition.