Previously we have shown you how to remotely connect to your Linux machine from a Windows one (Click here). Now, what if you need to transfer some files between your Windows and Linux systems?
Well, a USB drive comes handy for simple data transfers. For a large number of files at different times, you need another efficient method. Transferring your data between Linux and Windows using your local network is the recommended option. With an easy and quick one time setup, you can share your files between various machines.
File Sharing between Linux and Windows Systems
In this tutorial, we shall walk you through sharing your files between Ubuntu and Windows machines over a local network.
Transferring files between Ubuntu and Windows can be done in many ways, but in this tutorial, we are going to discuss the following popular methods:
- Transfer files between Ubuntu and Windows via the SSH.
- Transfer files between Ubuntu and Windows using Samba.
- Transfer files between Ubuntu and Windows using Shared Network Folders.
Method 1: Transfer Files Between Ubuntu And Windows Via SSH
In this method, you need to install and enable SSH service on Ubuntu. Also, we need an SSH client application on Windows. In this tutorial, we shall be using Putty. Next, we are going to use the command line to share your files across the network.
Step 1. Install the SSH package on Ubuntu using the next command.
sudo apt install openssh-server
Step 2. After installation finishes successfully, you can check the SSH service status using the following command.
sudo service ssh status
The output of the command should look like the below screenshot:
If the service is not running, you can use the following command to start it:
sudo service ssh start
Also, to enable the SSH service to start every time your system starts up, you can use the following command:
sudo service ssh enable
Step 3. Install the net-tools package.
sudo apt install net-tools
Step 4. Execute the next command to get your Ubuntu machine IP.
Step 5. From your Windows machine, we need an SSH client (which is Putty) and a PSCP. PSCP is considered a secure copy tool that is used alongside with Putty to transfer files securely over a network.
You can download both (Putty and PSCP) from Putty official website. (Click here.) Kindly note that Putty will need to be installed while the PSCP won’t. You have to put the PSCP.exe in the “C:\” drive to be used as you should see shortly.
Step 6. Now open the file explorer and use the next command to start transferring your files from your Windows machine to Ubuntu.
c:\pscp "C:\Ubuntu Tutorials\Windows Shared Folder\Windows Shared Folder.txt" email@example.com:windowssharedfile.txt
Step 7. Next, you should enter your Ubuntu password.
Step 8. After entering the password successfully, the command shall copy the text file from your Windows machine to your Ubuntu home. You can check your home directory now, and you should find the file there.
Step 9. Now in case you need to transfer your files from Ubuntu machine to Windows, open the file explorer from your Windows machine and use the next command. Be careful and do not forget the dot at the end of the command.
c:\pscp firstname.lastname@example.org:ubuntushared .
By executing the previous command, you should enter the password of your Ubuntu machine. Next, the file gets transferred from Ubuntu to the Windows current directory.
Method 2: Transfer Files Via Samba
In this method, we are going to install the Samba package on Ubuntu. Moreover, use the Windows run application to connect to the Ubuntu shared directories.
Step 1. Install the Samba package on Ubuntu using the following command.
sudo apt install samba
Step 2. You can set a password to the samba share as follows.
sudo smbpasswd -a hendadel
where hendadel is an Ubuntu user that you shall use while accessing the Ubuntu shared directory.
Step 3. Let’s create a directory that is used for sharing your files.
Step 4. Using your favorite text editor, open the samba configuration file.
sudo vi /etc/samba/smb.conf
Step 5. Add the next lines at the end of the samba configuration file.
[UbuntuSharedDir] path = /home/hendadel/UbuntuSharedDir available = yes valid users = hendadel read only = no browsable = yes public = yes writable = yes
The samba configuration file should like the below:
Save and exit the samba configuration file.
Step 6. Restart the samba service using the following command:
sudo service smbd restart
Step 7. From the Windows machine, open the run application from the Start menu and enter the Ubuntu machine IP with the shared directory name as follows.
Press the OK button to continue.
Step 8. A Windows Security message will appear, you should have to enter your samba username and password. Then press the OK button to continue.
Step 9. Now you should have access to your Ubuntu shared directory, and you can transfer files.
Method 3: Shared Network Folders
This is the easiest method among all. In this method, we share any folder from the Windows machine to be visible in the Ubuntu machine.
Step 1. From the Windows machine, right-click on the network connections icon in the right bottom of the taskbar.
Step 2. Choose the “Open Network & Internet Settings.”
Step 3. Next, choose “Sharing Options.”
Step 4. Now from your current network profile, choose the following options:
- Turn on network discovery.
- Turn on file and printer sharing.
Don’t forget to save your changes.
Step 5. Now open your file explorer and go to the directory that you need to share. Right-click on the folder then select Properties.
Step 6. After opening the folder properties, let’s choose the Sharing tab. Also, select the Advanced Sharing button.
Step 7. Mark “Share this folder” box.
In case you need to set permissions on the shared folder like (Read, Write) you can select the permissions button and set your permissions.
Press the OK button to continue.
Step 8. Now from the Ubuntu machine, open the file browser.
Step 9. From the left panel, choose “Other Locations.”
Step 10. In the bottom bar, enter your Windows machine IP and path to the shared folder as follows:
smb://192.168.1.6/Windows Shared Folder
Then press the Connect button.
Step 11. An authentication message should appear. Enter your username and password. Press the Connect button to continue.
Step 12. Next, you should be able to see your Windows shared folder. Now you can transfer files between the two machines.
That’s it for now about various methods that can be used for transferring files between Windows and Linux.