How to share files between a Linux and Windows computer

Updated: 04/26/2017 by Computer Hope

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.

  1. Open the Control Panel.
  2. Go to Network and Sharing Options.
  3. Go to Change Advanced Sharing Settings.
  4. 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.

  1. Right-click the folder and select Properties.
  2. Go to the Sharing tab.
  3. Above the Share... button is the network name of the share you're about to create. It should look like \\YOURCOMPUTERNAME\Users\YourUserName\ShareFolderName. Make a note of this network name to use later on your Linux machine.
  4. 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:

  1. Click the K menu icon.
  2. Select Internet -> Konqueror.
  3. In the Konqueror window that opens, click the Network Folders link, or type remote:/ in the address bar and press Enter.
  4. Click the Samba Shares icon.
  5. Click the icon of your Windows Home workgroup.
  6. Click the Workgroup icon.
  7. Click the icon for your computer.
  8. When prompted, enter the username and password for the Windows account that created the share.
  9. 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:

  1. Open Nautilus.
  2. From the File menu, select Connect to Server...
  3. In the Service type: drop-down box, choose Windows share.
  4. In the Server: field, enter the name of your computer.
  5. 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:

\\YOURCOMPUTERNAME\Users\YourUserName\ShareFolderName

Type smb://YOURCOMPUTERNAME/Users/YourUserName/ShareFolderName and press enter. Note the smb: at the beginning, and that on Linux you should 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.

  1. Open a terminal.
  2. Type smbclient at the command prompt.
  3. 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.

    1. If you use the apt package manager, which is the default on Linux systems such as Ubuntu or Debian, you can use the sudo apt-get install smbclient command.
    2. If you use the yum package manager, which is the default on Linux systems such as CentOS, you can use the sudo yum install samba-client command.
    3. You can also download the Samba client directly at www.samba.org/samba/download/ which might be useful to you if you need or want to compile the program from the source code.
  4. Once you're sure that smbclient is installed, you can connect to your Windows share using the command smbclient //ComputerName/ShareName -U Username (For instance, if your Windows user name is Fred and your Windows share network name was listed as \\YOURCOMPUTERNAME\Users\YourUserName\ShareFolderName, you should use the command smbclient //YOURCOMPUTERNAME/Users/YourUserName/ShareFolderName -U Fred. Notice that the Linux command uses forward slashes instead of backslashes).
  5. Enter your password.
  6. Once authenticated, you are placed at an smb: \> prompt.
  7. Here, you can use the ls command to list files.
  8. Use the command get filename.ext to transfer a file named filename.ext from your Windows share to your Linux machine, for example.
  9. Type help for a listing of further commands.
  10. Type quit or exit to return to the command prompt.

Additional information