How to Share Files Between Windows and Linux

By Korbin Brown on December 2nd, 2013

 

We’ve previously covered various ways to share files between nearby computers, but sharing between Windows and Linux can be a little more complex. This article will show you how to map shares across both operating systems for seamless file sharing.

There are two parts to this guide. In the first part, we’ll create a shared folder on Windows, and then configure Linux to access that share. In the second part, we’ll create a shared folder on Linux and configure Windows to access the share. Depending on your situation, you’ll want to follow the appropriate set of instructions. If, for some reason, you want to set up shared folders on both systems, you can do that, too. We’re using Windows 10 and Ubuntu for our examples, but we’ve made the instructions adaptable to pretty much any version of Windows or Linux.

Option One: Create a Share on Windows and Access It From Linux

To make this work, we’ll be taking three steps. First, we’ll make sure sharing is enabled on Windows. Once it is, we’ll share the actual folder. And then, we’ll look at how to access that folder from a Linux system.

Step One: Make Sure Sharing is Enabled in Windows

To set up a shared folder on Windows for Linux to access, start by making sure your network settings are configured to allow the connection from the other computer by opening the Network and Sharing Center. The easiest way to do this is to right-click the network icon in your system tray and choose “Open Network and Sharing Center.”

In the Network and Sharing Center window, click on “Change advanced sharing settings.”

For your current profile, make sure the following two settings are enabled:

  • Turn on network discovery
  • Turn on file and printer sharing

When you’re done, click “Save Changes.”

Step Two: Share the Folder

Now that sharing is enabled, we can create the shared folder for the Linux machine to see. There are no limitations to what you can share (you could theoretically share your entire hard drive), but here, we’ll just be sharing a folder named “Share” that is located on our Desktop.

Right-click the folder you want to share over the network, and then click “Properties.” On the “Sharing” tab of the properties window, click the “Advanced Sharing” button.

In the “Advanced Sharing” window that opens, enable the “Share this folder” option, and then click the “Permissions” button.

In the permissions window, you can restrict access to the folder to certain accounts. To let any user have access to your folder, just give the “Full Control” permission to the “Everyone” user. This allows anyone to read and write changes to files in the shared folder. If you would rather restrict access to certain accounts, just remove the Everyone user, add the users you want, and then assign them appropriate permissions.

Note: These user accounts are on the Windows computer, not Linux.

When you’re done setting up users and permissions, click “OK” to close the permissions window and then click “OK” again to close the “Advanced Sharing” window.

Back in the main properties window, switch over to the “Security” tab.

For the Linux user to have access to the shared folder, you need to configure the same permissions here that you configured in the sharing settings. If the two settings don’t match, the most restrictive settings will take effect. If your desired user already has their security permissions set up (such as the geek user in our example) then you’re good to go. You can close the window and move on to the next step.

If you do need to add a user, such as “Everyone,” click the “Edit” button.

In the permissions window that opens, click the “Add” button to enter the new user’s details.

Click “OK” on all the open windows, and your folder should now be shared with the network.

Step Three: Access the Windows Share from Linux

You should be able to mount the shared folder by using the GUI in Linux, but it’s also very easy to do with the command line. We’re going to use terminal for our examples not only because it’s quicker, but because it will work across many different distributions.

First, you’ll need the cifs-utils package in order to mount SMB shares. Just type the following command at the terminal:

sudo apt-get install cifs-utils

After that, just make a directory, and then mount the share to it. In this example, we will create the folder on our Desktop for easy access. Use these commands to create and mount the folder:

mkdir ~/Desktop/Windows-Share sudo mount.cifs //WindowsPC/Share /home/geek/Desktop/Windows-Share -o user=geek

As you can see in the screenshot, we were prompted for the root password of the Linux machine, and then for the password of the “geek” account on Windows.  After running that command, we are now able to see the contents of the Windows share and add data to it.

In case you need help understanding the mount command, here’s a breakdown:

  • sudo mount.cifs: This is just the mount command, set to mount a CIFS (SMB) share.
  • WindowsPC: This is the name of the Windows computer.  Type “This PC” into the Start menu on Windows, right click it, and go to Properties to see your computer name.
  • //Windows-PC/Share: This is the full path to the shared folder.
  • /home/geek/Desktop/Windows-Share: This is where we’d like the share to be mounted on the Linux system.
  • -o user=geek: This is the Windows username that we are using to access the shared folder.

Option Two: Create a Share on Linux and Access It from Windows

Creating a share on Linux and then accessing it from Windows is actually a bit easier than the other way around. First, we’ll create the shared folder on the Linux system. Then, we’ll look at how to access it from a Windows PC.

Step One: Create the Share on Linux

To set up a shared folder on a Linux that Windows to access, start with installing Samba (software that provides access to SMB/CIFS protocols used by Windows). At the terminal, use the following command:

sudo apt-get install samba

After Samba installs, configure a username and password that will be used to access the share:

smbpasswd -a geek

Note: In this example, we are using ‘geek’ since we already have a Linux user with that name, but you can choose any name you’d like.

Create the directory that you’d like to share out to your Windows computer.  We’re just going to put a folder on our Desktop.

mkdir ~/Desktop/Share

Now, use your favorite editor to configure the smb.conf file. We’re using Vi here.

sudo vi /etc/samba/smb.conf

Scroll down to the end of the file and add these lines:

[<folder_name>] path = /home/<user_name>/<folder_name> available = yes valid users = <user_name> read only = no browsable = yes public = yes writable = yes

Obviously, you’ll need to replace some of the values with your personal settings.  It should look something like this:

Save the file and close your editor.  Now, you just need to restart the SMB service for the changes to take effect.

sudo service smbd restart

Your shared folder should now be accessible from a Windows PC.

Step Two: Access the Linux Share from Windows

Now, let’s add the Linux share to our Windows Desktop.  Right-click somewhere on your Desktop and select New > Shortcut.

Type in the network location of the shared folder, with this syntax:

\\IP-ADDRESS\SHARE-NAME

Note: If you need the IP of your Linux computer, just use the ifconfig command at the terminal.

In the shortcut wizard on the Windows PC, click Next, choose a name for the Shortcut, and then click Finish. You should end up with a Shortcut on your Desktop that goes right to the Linux share.

Korbin Brown is an IT enthusiast with a passion for writing. He enjoys troubleshooting complex Windows, Linux, and networking issues and sharing his experiences with fellow geeks.

  • Published 12/2/13
More Articles You Might Like

Enter Your Email Here to Get Access for Free:

Go check your email!