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 computer.
- Open the Control Panel.
- Select the Network and Sharing Options or Network and Sharing Center option.
- Click the Change advanced sharing settings link in the left navigation menu.
- Click the Turn on Network Discovery and Turn on File and Print Sharing options.
- Click the Save changes button at the bottom of the Advanced sharing settings window.
Now, create a new folder to share or choose an existing folder that you want to share.
Following the steps below, creates a shared folder on your Windows computer that lets you access files in that folder on your Linux computer. With the right permissions you can also copy, edit, and delete files in that folder from your Linux computer.
Right-click the folder and select Properties.
Go to the Sharing tab.
If you want to share the folder with another Windows account, click the Share button, add the account to grant permission to access the shared folder, and click the Share button.
Click the Advanced Sharing button.
On the Advanced Sharing window, check the box for Share this folder and click OK.
The network path for the folder is now displayed above the Share button, indicating that it is now a shared folder. For example, it may look something like \YOURCOMPUTERNAME\Users\YourUserName\ShareFolderName. Make a note of this network folder path to use later on your Linux machine.
Access a Windows shared folder from Linux using Konqueror
Many Linux distributions use the KDE desktop environment and the Konqueror file manager/browser. If you’re using this, you can follow these steps to access your Windows shared folder.
If you shared the folder with another Windows account, you need to click the Advanced Sharing button, then click the Permissions button. Select the account, check the Allow box for the Change or Modify permission, and click OK.
- 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 you’re using this, 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 example, 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, 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 shared folder from the Linux command line using the smbclient program.
Open a terminal.
Type smbclient at the command prompt.
If you receive a “Usage:” message, smbclient is installed, and you can skip to the next step. However, if the command is not found, you need to install smbclient. Follow these steps to install it.
If you use the apt package manager, 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, 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.
With smbclient installed, you can connect to your Windows share using the command smbclient //ComputerName/ShareName -U Username. For instance, if your Windows username is Fred, and your Windows share network name is \YOURCOMPUTERNAME\Users\YourUserName\ShareFolderName, 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 or dir 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. If the file name contains spaces, make sure to enclose it in double quotes, for example: get “My new file.txt”.
Type help for a listing of further commands.
Type quit or exit to return to the command prompt.
If you use the apt package manager, 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, 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.
Related information
- See or shared directory definition for related links and information.
- Network and network card help and support.