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.
- Go to 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, you will see 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
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:
- Click the K menu icon
- Select Internet -> Konqueror
- In the Konqueror window that opens, click the Network Folders link, or typeremote:/ 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: dropdown 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, if when you created your Windows Share, the share name was listed as\\YOURCOMPUTERNAME\Users\YourUserName\ShareFolderName, you would 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.
- Open a terminal
- At the command prompt, type smbclient
- 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:
- If you use the apt package manager, which is the default on Linux systems such as Ubuntu or Debian, you can use the command sudo apt-get install smbclient
- If you use the yum package manager, which is the default on Linux systems such as CentOS or Fedora, you can use the command sudo yum install samba-client
- 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 will be 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