Sharing files between Linux and Windows systems is surprisingly easy with some fine accommodations from the Linux community. Let's look at two very different ways to make this happen. Credit: Anne Worner Many people today work on mixed networks, with both Linux and Windows systems playing important roles. Sharing files between the two can be critical at times and is surprisingly easy with the right tools. With fairly little effort, you can copy files from Windows to Linux or Linux to Windows. In this post, we’ll look at what is needed to configure your Linux and Windows system to allow you to easily move files from one OS to the other. Copying files between Linux and Windows The first step toward moving files between Windows and Linux is to download and install a tool such as PuTTY’s pscp. You can get PuTTY from putty.org and set it up on your Windows system easily. PuTTY comes with a terminal emulator (putty) as well as tools like pscp for securely copying files between Linux and Windows systems. When you go to the PuTTY site, you can elect to install all of the tools or pick just the ones you want to use by choosing either the installer or the individual .exe files. You will also need to have ssh-server set up and running on your Linux system. This allows it to support the client (Windows side) connection requests. If you don’t already have an ssh server set up, the following steps should work on Debian systems (Ubuntu, etc.). sudo apt update sudo apt install ssh-server sudo service ssh start For Red Hat and related Linux systems, use similar commands: sudo yum install openssh-server sudo systemctl start sshd Note that if you are running a firewall such as ufw, you may have to open port 22 to allow the connections. Using the pscp command, you can then move files from Windows to Linux or vice versa. The syntax is quite straightforward with its “copy from to” commands. Windows to Linux In the command shown below, we are copying a file from a user’s account on a Windows system to the /tmp directory on the Linux system. C:Program FilesPuTTY>pscp Usersshscopy_me.txt shs@192.168.0.18:/tmp shs@192.168.0.18's password: copy_me.txt | 0 kB | 0.1 kB/s | ETA: 00:00:00 | 100% Linux to Windows Moving the files from Linux to Windows is just as easy. Just reverse the arguments. C:Program FilesPuTTY>pscp shs@192.168.0.18:/tmp/copy_me.txt Usersshs shs@192.168.0.18's password: copy_me.txt | 0 kB | 0.1 kB/s | ETA: 00:00:00 | 100% The process can be made a little smoother and easier if 1) pscp is in your Windows search path and 2) your Linux system is in your Windows hosts file. Windows search path If you install the PuTTY tools with the PuTTY installer, you will probably find that C:Program filesPuTTY is on your Windows search path. You can check to see if this is the case by typing echo %path% in a Windows command prompt (type “cmd” in the search bar to open the command prompt). If it is, you don’t need to be concerned with where you are in the file system relative to the pscp executable. Moving into the folder containing the files you want to move will likely prove easier. C:Usersshs>pscp copy_me.txt shs@192.168.0.18:/tmp shs@192.168.0.18's password: copy_me.txt | 0 kB | 0.1 kB/s | ETA: 00:00:00 | 100% Updating your Windows hosts file Here’s the other little fix. With administrator rights, you can add your Linux system to the Windows host file (C:WindowsSystem32driversetchosts) and then use the host name in place of its IP address. Keep in mind that this will not work indefinitely if the IP address on your Linux system is dynamically assigned. C:Usersshs>pscp copy_me.txt shs@stinkbug:/tmp shs@192.168.0.18's password: hosts | 0 kB | 0.8 kB/s | ETA: 00:00:00 | 100% Note that Windows host files are formatted like the /etc/hosts file on Linux systems — IP address, white space and host name. Comments are prefaced with pound signs. # Linux systems 192.168.0.18 stinkbug Those pesky line endings Keep in mind that lines in text files on Windows end with both a carriage return and a linefeed. The pscp tool will not remove the carriage returns to make the files look like Linux text files. Instead, it simply copies the files intact. You might consider installing the tofrodos package to enable you to use the fromdos and todos commands on your Linux system to adjust the files you are moving between platforms. Sharing folders between Windows and Linux Sharing folders is an entirely different operation. You end up mounting a Windows directory on your Linux system or a Linux directory on your Windows box so that both systems can use the same set of files rather than copying the files from one system to the other. One of the best tools for this is Samba, which emulates Windows protocols and runs on the Linux system. Once Samba is installed, you will be able to mount a Linux folder on Windows or a Windows folder on Linux. This is, of course, very different than copying files as described earlier in this post. Instead, each of the two systems involved will have access to the same files at the same time. More tips on choosing the right tool for sharing files between Linux and Windows systems are available here. 2-Minute Linux Tip: How to add and delete user accounts Related content how-to How to find files on Linux There are many options you can use to find files on Linux, including searching by file name (or partial name), age, owner, group, size, type and inode number. By Sandra Henry Stocker Jun 24, 2024 8 mins Linux opinion Linux in your car: Red Hat’s milestone collaboration with exida With contributions from Red Hat and critical collaborators, the safety and security of automotive vehicles has reached a new level of reliability. By Sandra Henry Stocker Jun 17, 2024 5 mins Linux how-to How to print from the Linux command line: double-sided, landscape and more There's a lot more to printing from the Linux command line than the lp command. Check out some of the many available options. By Sandra Henry Stocker Jun 11, 2024 6 mins Linux how-to Converting between uppercase and lowercase on the Linux command line Converting text between uppercase and lowercase can be very tedious, especially when you want to avoid inadvertent misspellings. Fortunately, Linux provides a handful of commands that can make the job very easy. By Sandra Henry Stocker Jun 07, 2024 5 mins Linux PODCASTS VIDEOS RESOURCES EVENTS NEWSLETTERS Newsletter Promo Module Test Description for newsletter promo module. Please enter a valid email address Subscribe