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'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.
- Click Share...
Access a Windows shared folder from Linux, using Konqueror
- 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, choose 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, and that on Linux you should use forward slashes instead of backslashes.
Access a Windows shared folder from Linux, using the command line
- 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.
- 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.
- 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.
- 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.
- 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).
- Enter your password.
- Once authenticated, you are placed at an smb: \> prompt.
- Here, you can use the ls command to list files.
- Use the command get filename.ext to transfer a file named filename.ext from your Windows share to your Linux machine, for example.
- Type help for a listing of further commands.
- Type quit or exit to return to the command prompt.
- See or shared directory definition for related links and information.