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.”
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:
sudo smbpasswd –a USERNAME
Replace USERNAME with your own user name.
sudo cp /etc/ samba/ smb.conf /etc/samba/smb.conf.old sudo nano /etc/samba/smb.conf
8. Find the global section and add the lines:
encrypt passwords = true wins support = yes
9. Press Ctrl + O and Ctrl + X to save and exit.
10. Restart Samba:
sudo service smbd restart
11. Go to the Windows machine and right-click Start, then select Run.
12. In the Run box, type the command:
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
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:
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.”
2. Select “Network and Sharing Center.”
3. The Network and Sharing Center window will open. Click “Change Advanced settings.”
4. Enable these two settings: “Network Discovery” and “Turn on file and printer sharing.”
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.”
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:
sudo apt-get install cifs-utils
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:
mkdir ~/Desktop/Windows-Share sudo mount.cifs //WindowsPC/Share/home/username/Desktop/Windows-Share –o user=username
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.
Our latest tutorials delivered straight to your inbox