How to Transfer Files Between Linux and Windows via LAN

You’ve tried to use a flash drive or SD card to transfer files from Linux to a Windows computer, and you found it annoying and tiring, especially when there are lots of files to move, and it’s taking ages to complete.

You don’t have to waste your precious time using storage devices when you can move files quickly and easily over your local network (LAN).

The main methods used to do this are:

  • Create a share in Linux to access it from Windows using Samba
  • Create a share in Windows to access it from Linux

Create a share in Linux and access it from Windows using Samba

The best and fastest way to do this is by installing the Samba suite. Samba is an ideal solution for sharing files between different devices such as a Windows, Linux or Mac machines. The machines need to be networked with a generic router.

Windows machines come with functionality that allows them to work with Samba out of the box, so you only need to install one package for Linux machines.

1. On your Linux machine open the location containing the files you wish to share.

2. Right-click on the file and select “Sharing Options.”

transfer-files-linux-windows-via-lan-sharing-options

3. If you get a prompt asking you to install Samba services, click “Install service.”

4. Click Restart session once Samba service is installed to enable sharing.

5. Check the “Share this folder” and “Allow others to create and delete files in this folder” boxes.

6. Click “Create Share” to complete the process.

7. Open Terminal and type the following commands:

Replace USERNAME with your own user name.

8. Find the global section and add the lines:

9. Press Ctrl + O and Ctrl + X to save and exit.

10. Restart Samba:

11. Go to the Windows machine and right-click Start, then select Run.

12. In the Run box, type the command: \\computer_name\share_name5.

Note: the computer name in this case can be the IP address of the Linux machine, which you can find by going to the Linux computer and opening terminal, then typing ipconfig.

13. Type the Linux computer name and share the resource name.

14. A prompt will be displayed asking for your credentials.

15. Type in your Linux username and password. Click OK.

16. Try to access the shares from your Windows computer.

The new server should be displayed in “My Network Places” in Windows.

Alternatively, do the following: right click Start and select Run, then enter: //server. Replace server with the name or IP address of the machine that runs your Samba server. A window with the browsable shares from the server will open.

Note: to access non-browsable shares, use this code: \\server\share name

Create a share in Windows to access it from Linux

This will be done in three steps as follows:

  • Enable sharing on Windows
  • Share the folder
  • Access it from Linux

Enable sharing on Windows

Start by ensuring the network settings are configured to allow a connection from the Linux system. To do this:

1. Go to Control Panel and click “Network and Internet.”

transfer-files-linux-windows-via-lan-control-panel-network-and-internet

2. Select “Network and Sharing Center.”

transfer-files-linux-windows-via-lan-control-panel-network-and-internet-network-and-sharing-center

3. The Network and Sharing Center window will open. Click “Change Advanced settings.”

transfer-files-linux-windows-via-lan-control-panel-network-and-internet-network-and-sharing-center-change-advanced-settings

4. Enable these two settings: “Network Discovery” and “Turn on file and printer sharing.”

transfer-files-linux-windows-via-lan-network-and-sharing-center-enable

5. Click Save changes.

6. Sharing is now enabled.

Share the folder

Create a shared folder for the Linux system to see, connect and access. You can share anything, so follow these steps:

1. Find the folder you want to share and right-click it.

2. Select “Properties.”

transfer-files-linux-windows-via-lan-file-explorer-properties

3. Under the Sharing tab, click “Advanced Sharing.”

4. Under the Advanced Sharing window, enable the “Share this folder” option.

5. Click “Permissions.”

Note: in the Permissions window you can restrict access to the folder to specific users or accounts. Select “Full Control permission to Everyone” to give any user access. This way anyone can read and write changes to the files in the folder you share.

If, however, you want to restrict access to specific user accounts, remove the “Everyone” user, add the users you want and then assign the relevant permissions to them. The user accounts are those that are on the Windows system (not the Linux system).

6. Click OK to close the Permissions window.

7. Click OK to close the Advanced Sharing window.

8. Go to the Security tab in the main properties window.

Note: configure similar permissions as those in the sharing settings so that Linux users can access the shared folder.

If they don’t match, the most restrictive settings are applied.

However, if the user you intend to share with already has security permissions, close the window and move to the third step. Otherwise, click “Edit” to add a user, click “Add” in the Permissions window that opens, and enter the user’s details.

9. Click OK on all windows. The folder should now be shared with your network.

Access from Linux

You can mount the shared folder using Linux GUI or by using a command line. For our example we’ll use Terminal because it works across many distributions, and it’s faster.

To do this, you’ll need the cifs-utils package to mount SMB shares. The complete the following steps.

1. In the terminal, type:

2. Make a directory.

3. Mount the share to the directory

4. Create a folder on the desktop. (It’s easier to access from here.)

5. Create and mount the folder using these commands:

Note: if prompted for the root password of the Linux system and for your user account on Windows, insert each of them and run the command.

You’ll now see the contents of the Windows share and will be able to add data to it.

Are you now able to transfer files to and from Linux and Windows systems? Tell us what worked for you, and if you have a different method, share with us below.

4 comments

  1. Your are kidding or delusional. I’ve never, ever, been able to share anything via samba or anything else using my Ubuntu workstation and Windows PC’s. Installing samba, explicitly following instructions such as those you show above, always — ALWAYS — result in “permission denied” or “file doesn’t exist”. I just keep a spare 32gb micro SD card handy and use it for transfers. It is, appropriately, named “transfers”.

  2. couldn’t make it work

  3. Sorry, but I couldn’t make it work, either. Got this error message:
    “Couldn’t chdir to –o: No such file or directory”
    I’ll do some more testing and report back soon, in case anyone’s interested. :-)

  4. Following on from my last comment, I’ve been able to view Windows Shares in Ubuntu Mate 18.04.1 (32 bit with updates applied) but the key turned out to be a modification of the Samba config file “/etc/samba/smb.conf”, adding the line
    “client max protocol = NT1” in the section [Global]. Then I was able to see the Windows shares while browsing the network in Caja, the file manager included with Ubuntu Mate.
    I didn’t have to install cifs-utils, as far as I know.
    (Thanks to the Dedoimedo website for this tip. The author explains the problem very clearly. :-) )

Leave a Comment

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.