Copying folder from windows to linux

Copy Files Between Windows and Linux Using Command Line

It is not always that you will need to copy a file from Windows to Linux or vice versa. But at times when you are automating things or trying to achieve some copy functionality using a script, it is good to have a utility to do that. Here is where pscp comes into play. Using pscp you can copy the file to/from windows and Linux. In this guide, I will go through the steps of doing the same.

Copy File from Windows To Linux

1. Download pscp.exe from here

2. copy the pscp.exe executable to the system32 directory of your windows machine. This folder normally exists in C:\Windows\System32 path.

3. Open PowerShell and use the following command to verify if pscp is accessible from the path.

4. Use the following format to copy the file to the Linux box.

  1. -pw for the password.
  2. replace password with the Linux user password.
  3. C:\Users\Admin\Desktop\test.txt represents the path of the file that has to be copied to the Linux system.
  4. 192.168.33.10 is the IP of the Linux server.
  5. /home/vagrant is the user-accessible path in the Linux system to copy the file.

If you are using private keys for authentications, you can use -i flag instead of -pw followed by the path to the .ppk file. If your key file is in pem format, you can use the puttygen command to convert it to ppk.

Info: Learn Linux & Windows administration from Pluralsight with its 10 days free account

For key-based authentication, the command looks like below.

Читайте также:  Mac os x forums

Copy File From Linux To Windows

You can use pscp to copy files from Linux to windows. use the following command format for the same.

The above command will copy the file in Linux from the specified path to the Windows desktop.

SCP copy windows local file to linux remote folder

How to get a file from my path d:/test.txt and copy it to /etc/var/test/test.txt

but that didn’t worked, how to set the hard disk from where I copy my files?

11 Answers 11

Umm, if you’re using cygwin you want that command to look like

Or you can use WinSCP, you’ll probably find that simpler.

The best way to copy files from Windows to Linux using the command line is through pscp. It is very easy and secure. For pscp to work on your windows machine, you need it add its executable to your systems path. Once it is done, you can use the following format to copy the file.

You can refer the following blog post for more information on pscp setup.

Assuming you are on Windows, best way is to download and install cygwin. Get the path to the binary folder and add it to the system path. You can now run Linux commands on your command line.

Open the command prompt and go to the directory where your file is that you want to copy. Run the following command;

  • scp — secure copy command
  • file.txt — file you want to copy
  • root — username used to log onto CentOS machine
  • 1.1.1.1 — IP address of CentOS machine. Needless to say your Windows machine and the CentOS machine have to be able to communicate with one another
  • :/opt — This is the directory with which you save the file to, I generally save everything to the /opt directory
  • Don’t forget the @ between the username and IP Address and the : between the IP Address and directory you are saving the file to
Читайте также:  Можно ли восстановить точку восстановления windows

If you need a key to login into the server, enter the following;

For handiness sake I just copy the file I want to copy across to the key file directory, that way you know everything will run smoothly

2 Ways to Copy Files from Windows 10 to Windows Sub-System for Linux

Today we are going to discuss about how to copy file from your Windows 10 machine to Windows Sub-System for Linux.

Distribution Package of Windows Sub-System for Linux

First thing first, before you can even begin you have to understand where all the Linux files are placed in your Windows 10 machine. To avoid any accidental tampering Microsoft stores all you Linux files under the following hidden folder:

Here you can find your Linux distribution packages (distro) , double-click on the folder for your distribution, following is name of distribution package and folder name mapping:

Distribution Package Folder Name
Ubuntu CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc
openSUSE Leap 42 46932SUSE.openSUSELeap42.2_022rs5jcyhyac
SUSE Linux Enterprise Server 12 46932SUSE.SUSELinuxEnterpriseServer12SP2_022rs5jcyhyac

For Ubuntu which I’m using, I’ll look for CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc and then navigate to folder navigate to .\LocalState\rootfs\ folder. This is the root file share where all you files are placed

Copy Files

Method 1 – Manual Copy-Paste

You can simply move or copy-paste files inside one of these Linux directories,

but the files won’t appear in you Windows Sub-system for Linux Bash Shell until you restart it.

Method 2 – Windows System Drive as a Mount point

Windows Sub-System for Linux provides you access to the Windows 10 system drive by mounting the C:\ . On Linux if you go to you root directory and list all directories, then you will notice a /mnt/c/ which is Windows 10 C:\ mounted on Linux

Now simply use copy command ( cp ) to copy files over to your Linux Subsystem.

Video Tutorial

If you like this article read more similar articles under ‘N – Ways to’ category

My New Book : PowerShell Scripting Guide to Python

This PowerShell Scripting guide to Python is designed to make readers familiar with syntax, semantics and core concepts of Python language, in an approach that readers can totally relate with the concepts of PowerShell already in their arsenal, to learn Python fast and effectively, such that it sticks with readers for longer time.

“Use what you know to learn what you don’t. ” also known as Associative learning.

Book follows a comparative method to jump start readers journey in Python, but who is the target audience? and who should read this book –

  • Any System Administrator who want to step into Development or Programming roles, and even if you don’t want to be a developer, knowledge of another scripting language will make your skill set more robust.
  • Python Developers who want to learn PowerShell scripting and understand its ease of user and importance to manage any platform.

Python is one of the top programming languages and in fast changing IT scenarios to DevOps and Cloudto the future – Data Science, Artificial Intelligence (AI) and Machine Learning Python is a must know.

But this PowerShell Scripting guide to Python would be very helpful for you if you already have some knowledge of PowerShell

NOTE! This is a Leanpub “Agile-published” book. That means the book is currently unfinished and in-progress. As I continue to complete the chapters, we will re-publish the book with the new and updated content. Readers will receive an email once a new version is published!

While the book is in progress, please review it and send any feedback or error corrections at [email protected]

Follow @SinghPrateik

Читайте также:  Снятие образа windows 10 для развертывания
Оцените статью