Copy files from windows to ubuntu

I wanna transfer some files from this PC with Ubuntu to a PC with Windows 7 I don't care how to do it (ftp, samba or whatever) I wanna know the steps, I searched a lot but I can't find anything that

Share Folders in Ubuntu 11.10

Objectives: Share a folder in Ubuntu and access it from Windows

To get started, right-click on the folder you wish to share and select ‘Sharing Options’

screenshot

When prompted to install Samba services, do it.

screenshot

After installing Samba services, click ‘Restart session’

screenshot

Then click ‘Create Share’ to complete the process.

screenshot

Open Terminal Replace USERNAME with your account name.

sudo smbpasswd -a USERNAME

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old
sudo nano /etc/samba/smb.conf

scroll to the global section, and add the lines

encrypt passwords = true 
wins support = yes

press ctrl+o and ctrl+x to save, and exit nano

sudo service smbd restart

On the Windows machine, go to Start –> All Programs –> Accessories –> run and type the command:

\computer_nameshare_name

computer name can be ip address of ubuntu machine , to check ip of ubuntu machine , go to ubuntu machine & open terminal & type ifconfig

screenshot

Type the Ubuntu computer name and the share name of the resource.

You will get a prompted to enter your credentials. Type your Ubuntu username and password and click ‘OK’

screenshot

Now try again to access the shares from your Windows machine

screenshot

Transfer files From Ubuntu To Windows

On Ubuntu Machine install openssh-server

sudo apt-get install openssh-server

after installing go to windows machine & download / install FileZilla & open it

screenshot

  • Host = Ubuntu Machine Ip address
  • Username = Your Ubuntu Machine Username
  • Password = You Username Password
  • Port = 22

Done Now you can easily transfer files from Windows to Ubuntu OR Ubuntu to windows

Copying data from a Windows PC to Linux—or in the other direction—can seem intimidating at first. After all, it’s something that seems like it should be simple but turns out to be difficult.

In truth, sharing files from Windows to Linux is easy, but only if you know how to do it. Ready to find out? Here’s everything you need to know about how to transfer files from Windows to Linux and back again.

4 Ways to Transfer Files From Windows to Linux

If you want to move data between Windows and Linux operating systems, it’s easier than you think. We’ve compiled four ways for you to do this:

  1. Securely copy files via SSH
  2. Windows to Linux file transfer with FTP
  3. Share data using sync software
  4. Use shared folders in your Linux virtual machine

With each of these methods, you’ll be able to easily (and, in some cases, effortlessly) carry out Linux to Windows or Windows to Linux file transfer.

Let’s look at them in turn and find out which one suits you best.

1. Copy Files Between Windows and Linux via SSH

With SSH enabled on your Linux device, you can send data via the command line from one computer to another. For this to work, however, you will need to set up an SSH server on your Linux machine.

Start by opening a terminal and updating and upgrading the OS.

 sudo apt update
sudo apt upgrade

Once complete, install the SSH server. The OpenSSH server is a good option.

 sudo apt install openssh-server 

Wait while it installs. To check at any time if the OpenSSH server is running, use:

 sudo service ssh status 

To transfer data from Windows, use an SSH client like PuTTY. This needs the PSCP (secure copy client) tool to download to your Windows system to run alongside PuTTY. Find both on the PuTTY downloads page.

Download: PuTTY

Note that while PuTTY will need installing, PSCP won’t. Instead, save the downloaded pscp.exe file in the root of the Windows C: drive or else set it up as an environment variable. You’ll also need to confirm the IP address of the Linux device. Check in the Linux terminal with:

 hostname -I 

With a connection established, you can transfer a file from Windows to Linux like this:

 c:pscp c:somepathtoafile.txt user@remoteIP:homeusersomepathnewname.txt 

You’ll be prompted for your password for the Linux computer before the transfer commences.

Want to copy files from Linux to Windows in the same SSH session? This command will download the specified file to the current directory:

 c:pscp user@remoteIP:homeusersomefile.txt . 

Note the lone period at the end, which you must include, or the transfer will not work.

2. How to Transfer Files From Linux to Windows Using FTP

You can also use a file transfer protocol (FTP) application with SSH support. Transferring files via SFTP in a mouse-driven user interface is arguably easier than relying on typed commands.

Again, an SSH server must be running on the Linux machine before you start. You should also ensure you have installed an FTP app on Windows, like FileZilla, which has SFTP support.

Download: FileZilla

To use this method, run FileZilla, then:

  1. Open File > Site Manager
  2. Create a New Site
  3. Set the Protocol to SFTP
  4. Add the target IP address in Host
  5. Specify a username and password
  6. Set the Logon Type to Normal
  7. Click Connect when ready
Share files between Linux and Windows using FTP

You can then use the FTP app to move files from Windows to Linux and back using drag and drop.

Another option you should consider is a file-syncing program. These are typically cross-platform and use an encrypted key to manage the connection between devices.

All you need to do is install the app, nominate a sync folder, then create the key. Set this up on the second PC, and your data will then sync. Two good options are available for this:

  1. Resilio Sync: Formerly known as BitTorrent Sync, Resilio is available on almost any platform you can think of. There is a paid version, but the free option is enough for syncing two devices
  2. Syncthing: For Linux, Windows, macOS, and Android, this Resilio Sync alternative offers a similar feature without the paid component

4. How to Transfer Files From Windows to a Linux Virtual Machine

Instead of running a separate PC, it’s common to run Linux or Windows in a virtual machine (VM). But is there a way to transfer files between Windows and Linux when one is installed in a VM?

Fortunately, yes. With VirtualBox, you can create a virtual shared directory for data syncing.

If you’re running Windows in a VM on Linux (or vice versa), VirtualBox is already set up for sharing. Ensure you have the Guest Additions installed on your virtual machine before proceeding.

In the VirtualBox manager, select the VM, then:

  1. Choose Start > Headless Start (or with the VM running, Devices > Shared Folders)
    Enable a headless start for your VM
  2. Once running, right-click the VM and select Settings > Shared Folders
  3. Select Machine Folders
  4. Click the + symbol on the right (or right-click and select Add Shared Folder)
  5. Browse the Folder Path and find the directory you want to use
  6. Set a name (if necessary), then OK
    Share files between Windows and Linux in a virtual machine
  7. Use the Auto-mount checkbox to ensure the share is available whenever the VM runs
  8. Click OK again to confirm and exit

When you reboot the VM, the share will be ready to swap data between the host PC and the guest operating system.

There is another option for sharing files between Windows and Linux PCs. However, creating a shared file on one or both systems and then accessing it across a network is unreliable at best.

Sharing Files Between Windows and Linux Is Easy

Whether you’re new to Linux or you find Windows unfamiliar, sharing data between them is easier than you think. Now that you know how to transfer files from Windows to Linux and vice versa, we’d recommend you try all the methods we’ve mentioned above and work out which one you’re most comfortable with.

If you’re syncing data to Linux, there’s a good chance you’re switching from Windows. Don’t worry—it’s easier than you think.

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?

You Might Be Interested In

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, and we shall also show you how to transfer files between Windows and Linux on the same PC.

Over the 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:

  1. Transfer files between Ubuntu and Windows via the SSH.
  2. Transfer files between Ubuntu and Windows using Samba.
  3. 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

Install The Open SSH Package On Ubuntu

Install The Open SSH Package On Ubuntu

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:

Check The SSH Service Status

Check The SSH Service Status

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

Install net-tools Package

Install net-tools package

Step 4. Execute the next command to get your Ubuntu machine IP.

ifconfig

Ubuntu Machine IP

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 the 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 TutorialsWindows Shared FolderWindows Shared Folder.txt" hendadel@192.168.1.8:windowssharedfile.txt

Copy File From Windows To Ubuntu Via SSH

Copy File From Windows To Ubuntu Via SSH

Step 7. Next, you should enter your Ubuntu password.

Enter Your Ubuntu Password

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.

Check The Copied File

Check The Copied File

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 hendadel@192.168.1.8:ubuntushared .

Copy File From Ubuntu To Windows Via SSH

Copy File From Ubuntu To Windows Via SSH

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.

File Copied Successfully

File Copied Successfully

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

Install Samba Package On Ubuntu

Install Samba Package On Ubuntu

Step 2. You can set a password to the samba share as follows.

sudo smbpasswd -a hendadel

Add A User For Samba Share

Add A User For Samba Share

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.

mkdir /home/hendadel/UbuntuSharedDir

Create Directory For The Shared Data

Create Directory For The Shared Data

Step 4. Using your favorite text editor, open the samba configuration file.

sudo vi /etc/samba/smb.conf

Open Samba Configuration File

Open Samba Configuration File

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:

Edit Samba Configuration File

Edit Samba Configuration File

Save and exit the samba configuration file.

Step 6. Restart the samba service using the following command:

sudo service smbd restart

Restart Samba Service

Restart Samba Service

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.

\192.168.1.8UbuntuSharedDir

Remote Access To Your Ubuntu

Remote Access To Your Ubuntu

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.

Authentication Required

Authentication Required

Step 9. Now you should have access to your Ubuntu shared directory, and you can transfer files.

Welcome To Your Ubuntu Shared Directory

Welcome To Your Ubuntu Shared Directory

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.

Right Click On Network Connections

Right Click On Network Connections

Step 2. Choose the “Open Network & Internet Settings.”

Open Network and Internet Settings.

Open Network and Internet Settings.

Step 3. Next, choose “Sharing Options.”

Open Sharing Options

Open Sharing Options

Step 4. Now from your current network profile, choose the following options:

  • Turn on network discovery.
  • Turn on file and printer sharing.

Choose Options And Save Changes

Choose Options And Save Changes

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.

Open Folder Properties

Open Folder Properties

Step 6. After opening the folder properties, let’s choose the Sharing tab. Also, select the Advanced Sharing button.

Open Advanced Sharing

Open Advanced Sharing

Step 7. Mark “Share this folder” box.

Check The Share This Folder

Check The Share This Folder

In case you need to set permissions on the shared folder like (Read, Write), you can select the permissions button and set your permissions.

Set Sharing Permissions

Set Sharing Permissions

Press the OK button to continue.

Step 8. Now from the Ubuntu machine, open the file browser.

From Your Ubuntu Open The File Browser

From Your Ubuntu Open The File Browser

Step 9. From the left panel, choose “Other Locations.”

Open Other Locations

Open 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

Connect To Windows Shared Folder

Connect To 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.

Enter Your Windows Machine Username And Password

Enter Your Windows Machine Username And Password

Step 12. Next, you should be able to see your Windows shared folder. Now you can transfer files between the two machines.

Welcome To Your Windows Shared Folder

Welcome To Your Windows Shared Folder

Transferring files between Windows and Linux on the same machine

Previously, we looked at how we can share files between a Linux PC and a Windows PC over a network. Some of the utilities used included SSH, Samba, and Shared Network Folders. Here, we will look at a relatively similar situation only that this time around, it will be on the same machine.

You might be wondering why can’t we copy files directly from a Linux partition to a Windows partition and Vice-versa? The simple answer is that; It will work for one but doesn’t work for the other. Let’s look at the reasons behind this.

Why it isn’t easy

The NTFS partition format used by Windows doesn’t support Linux file permissions. Therefore, we can’t consider installing Linux on an NTFS partition other than the Ext4. On the other hand, Windows cannot read the Linux file system even though Linux systems can read an NTFS partition. In most cases, the Linux partition is not listed in the “This PC” section on Windows in a dual boot. Therefore, you can copy a file from the Windows partition on Linux but not the vice-versa.

A simple solution

With the above information in mind, we need to find a way to favor both operating systems and wouldn’t pose any data corruption issues. For example, if you delete or alter any file in the Windows partition while accessing it with Linux, there is a high probability that Windows might raise some errors on boot.

Since Linux can’t run on an NTFS or FAT32 partition and Windows can’t read a Linux file system, we will need to configure a third partition that can be accessed by both operating systems. This third partition will contain commonly shared files between the two. Let’s call it the SharedPartition.

We can use other methods to share files, including external storage like USB or online storage like Google Drive and DropBox. However, these are tedious as one will require a reboot to switch from one OS to another while the other method is dependent on bandwidth.

Create a SharedPartition

Whether you have an SSD or Hard drive, we will require at least Four partitions:

  • Linux Partition
  • Windows Partition
  • A SWAP space
  • The SharedPartition (NTFS)

I believe you already have the first three. To create the SharedPartition, you can safely check our post on ‘Creating or resizing partitions in Linux.‘ Ensure you format it to NTFS. Additionally, you might need to understand the partition Table used on your Drives. That can be GPT or MBR. Our post on ‘Booting Linux or Windows from a USB drive‘ gives you a comprehensive guide on this. You will also understand the advantage of one over the other.

Up to here, we already have a SharedPartition that can be accessed by both Operating Systems. However, we might need to perform some configurations like Auto-mount on Linux and setting it as the default location for various files.

Configure Auto-Mount on Linux

We will need to execute several commands on the command-line. If you are just getting started with, don’t panic. Please copy and paste the commands as they are below. Our Linux distribution of choice in this post is Ubuntu 20.04 LTS.

Note: Remember to replace the name SharedPartition with the label of your new partition in any of the commands.

Step 1. Install the ntfs-3g driver, which enables Linux to read and write NTFS partitions.

sudo apt install ntfs-3g

Install ntfs-3g

Install NTFS-3g

Step 2. Create a directory where we will mount our new partition.

sudo mkdir /media/SharedPartition

Create Mount directory

Create Mount directory

Step 3. Get the UUID (universally unique identifier) of the new SharedPartition with the command below.

sudo blkid

You should see an output like this.

Know your UUID

Know your UUID

Copy the UUID of the SharedPartition. The UUID identifies the partition in the /etc/fstab file.

Step 4. Since we will be editing the /etc/fstab file, create a backup with the command below.

sudo cp /etc/fstab /etc/fstab.backup

Step 5. Execute the command below to edit /etc/fstab using the nano editor.

sudo nano /etc/fstab

You should see a window like the one below. Add the following line at the end but remember to replace the UUID with yours.

# SharedStorage
UUID=66E53AEC54455DB2 /media/SharedPartition/ ntfs-3g auto,user,rw 0 0

Edit etc-fstab

Edit etc-fstab

After this step, reboot your PC. You should now see the SharedPartition mounted under the ‘Other Locations’ menu.

SharedPartition

SharedPartition

Configure your Special Folders (Linux)

Special folders in Linux are those present on your Home directory. They include Desktop, Documents, Videos, etc. Execute the below command to edit their paths.

sudo nano .config/user-dirs.dirs

Special Folders

Special Folders

Now, we need to edit the paths to point to our SharedPartition mounted in /media/SharedPartition. For example, for Downloads, we will add the path “/media/SharedPartition/Downloads” and delete the “$HOME/Downloads” path. After applying the changes, you should have something similar to this:

Special Folders

Special Folders

Save your changes and close the Nano editor.

Configure your Special Folders (Windows)

Step 1. Open the File Explorer and type %userprofile% on the address bar. Hit enter.

User Profiles

User Profiles

Step 2. Select a folder, say Downloads, that you want to access in both operating systems. Right-click and select the properties option.

Step 3. On the pop-up window that opens, select the Location tab.

Location Tab

Location Tab

You will see the default path to your Downloads location.

Step 4. Click on the Move button. That will open a window where you will select your new Downloads path. Navigate to your SharedPartition and choose the Downloads folder already created in Linux. Click on the Select Folder button.

Select Destination Folder

Select Destination Folder

Step 5. Click on the Apply button to set the changes.

You will see a pop-up window prompting you to move the content in the old folder to this new location. Click OK.

Apply Changes

Apply Changes

That’s it. You can now proceed to do the same for the other Folders. Now, anything you save on these folders, e.g., Documents on Windows, will be accessible on Linux in the Documents directory.

Using another partition to share files between the two operating systems is the most reliable option since Windows cannot read the Linux file system without using third-party software. With this method, you don’t need to have duplicate files. Both operating systems can read and write on the same partition.

You Might Be Interested In

In this updated guide, I will walk you through the steps to copy files from Windows to Linux using easy-to-follow steps.

I will show you two ways to copy files from windows to Linux

  1. Using command line with pscp
  2. Using GUI FTP utility.

Copy File from Windows To Linux Using PSCP

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.

Step 1: Download pscp.exe from here. Select the appropriate package.

Download pscp to copy files from windows to Linux

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

C folder location to save pscp.exe file

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

pscp

You should see the following output.

Step 4: Use the following format to copy the single file from Windows to the Linux box.

pscp -pw password C:UsersAdminDesktoptest.txt  
[email protected]:/home/vagrant

Here is the explanation of the command.

  1. -pw for the password.
  2. Replace password with the Linux user password.
  3. C:UsersAdminDesktoptest.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 want to copy all the files in a directory to Linux, you need to add a start to the folder. eg. folder*. An example is shown below.

pscp -pw password C:UsersAdminDesktopfolder*  
[email protected]:/home/vagrant

If you are using Linux private keys for authentication, you can use -i flag instead of -pw followed by the path to the .ppk , .pem or id_rsa file.

If your key file is in pem format, you can use the puttygen command to convert it to ppk. See this ec2 server guide for the pem to ppk conversion.

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

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

pscp -i /path/to/key.ppk C:UsersAdminDesktoptest.txt 
[email protected]:/home/vagrant

Copy File From Linux To Windows Using PSCP

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

pscp -pw password [email protected]:/path/to/file 
C:UsersAdminDesktop

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

Copy File from Windows To Linux Using FTP GUI

If you are not familiar with the Windows command line, you can use an FTP tool like Filezilla.

This tool is really helpful if you are working with Web Hosting providers to upload your website files from your local workstation.

You can download Filezilla from here –> FileZilla Download.

After download, install Filzill as you install any other windows software.

After installation, open the Filezilla app and enter the remote Linux server details as shown below. It will connect to the server and shows the remote server files in the file explorer.

Transfer files from windows to Linux using FTP

To upload a file, all you have to do is do a right-click and click upload, as shown in the image below. The file will get uploaded to the remote path, which is opened in the Filezilla explorer. You can also change the remote path from Filezilla.

Upload files from windows to Linux using Filezilla

Conclusion

I have shown two best and recommended ways to transfer files from Windows to Linux and vice versa.

If you face any issues while copying files, please drop the issues as a comment. I will look into it.

He loves to write about WordPress and cloud hosting. He is a Cloud Architect by profession with experience hosting high scale applications on Amazon and Google cloud platforms. He has successfully set up and grown several WordPress websites by following good tech practices.

I am using putty to connect to a linux computer using ssh. I am on a local windows machine that has a file. I want to transfer a file from my windows machine to the linux machine. How could I do this in command line without filezilla?

asked Apr 21, 2016 at 18:19

BishopSankey's user avatar

2

If ftp server is running in your Linux box then you can transfer files with filezilla (since it is ftp client). If that is not the case then download WinSCP a gui software like filezilla but uses SSH to transfer files.

answered Apr 21, 2016 at 18:25

kakurala's user avatar

kakuralakakurala

8146 silver badges15 bronze badges

If you are already on windows why not use GUI based clients? WinSCP is a good free client for transfers over SSH. It can transfer multiple files and also has auto resume facility.

answered Apr 21, 2016 at 18:27

Mrinal's user avatar

MrinalMrinal

3661 gold badge4 silver badges12 bronze badges

Using Putty’s PSCP command (which you can get from here) you can copy the file to your Linux computer by doing:

pscp.exe file_to_copy username@server_name:/path/destination_file_name

answered Apr 21, 2016 at 18:29

brandonhuddle's user avatar

The putty equivalent to scp is pscp. Get it where you got putty

scp is the ssh way to copy files to and from something running a ssh server. So you could send your file from the windows machine to Linux on the windows command line

answered Apr 21, 2016 at 18:23

infixed's user avatar

infixedinfixed

1,1257 silver badges14 bronze badges

We can do that using winscp. The command will be:

From command promopt:

scp «C:files*.*» username@linuxserver:/home/files/

answered Apr 29, 2020 at 3:26

Robi's user avatar

RobiRobi

731 silver badge7 bronze badges

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

I’ve tried this:

scp d:/test.txt /etc/var/test/test.txt

but that didn’t work.

How do I set the hard disk from where I copy my files?

clabacchio's user avatar

asked Mar 14, 2014 at 10:30

user3414354's user avatar

1

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

scp /cygdrive/d/test.txt <linux ip>:/etc/var/test/test.txt

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

answered Mar 14, 2014 at 10:47

quadruplebucky's user avatar

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.

pscp -pw password D:test.txt user@192.168.33.10:/etc/var/test/test.txt

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

http://comtechies.com/2016/02/copy-files-between-windows-and-linux.html

answered Feb 25, 2016 at 10:13

Bibin Wilson's user avatar

2

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 file.txt root@1.1.1.1:/opt/
  • 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

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

scp key.pem file.txt root@1.1.1.1:/opt

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

answered Mar 20, 2014 at 17:15

Dan's user avatar

DanDan

1951 silver badge7 bronze badges

I would highly recommend to use WinSCP if you’re a Windows user. It has a good intuitive interface and gets the job done easily and with no pain.

Download link

enter image description here

answered Oct 1, 2015 at 19:52

Andrei's user avatar

AndreiAndrei

1611 silver badge3 bronze badges

to copy a file from windows to linux write:

scp -i privatekey pathFileOnWindows user@publicIp:pathDirectoryLinux 

(the colon : is important!)

Example:

//I am located here in my console

C:Usersoscar>

//I’m executing the next command

scp -i C:UsersoscarDocumentsllavesubuntu.pem C:UsersoscarDocumentsindex.html ubuntu@ec2-54-94-247-176.sa-east-1.compute.amazonaws.com:~/

You can puth the full path or location in the path where the file is located. ~/ means the home directory of the user ubuntu

Jenny D's user avatar

Jenny D

27.5k21 gold badges74 silver badges111 bronze badges

answered Mar 19, 2019 at 3:47

Oscar Javier Gómez Sánchez's user avatar

1

If you are on the remote machine:

scp user@hostname:D:text.txt user@hostname:/etc/var/test/test.txt

If you are currently on Windows machine:

winscp D:text.txt user@hostname:/etc/var/test/test.txt

henrycarteruk's user avatar

answered Mar 14, 2014 at 10:56

pulsarjune's user avatar

pscp with -pw exposes my password, which I don’t like. The below answer works just like me using scp on linux -> linux.

pscp -scp C:Windowsfoo.txt username@10.0.0.1:/foo/bar

answered Aug 23, 2019 at 22:06

lobi's user avatar

lobilobi

1,0512 gold badges15 silver badges30 bronze badges

First you have to install any ssh client (OpenSSH) which support command line interface for your windows machine:

And add its path to windows Variable:

My Windows System output like below:

enter image description here

Then you will able to execute the same commands on your windows machine

You can copy also complete directory by executing:

scp -r path/to/dir_name/* user@remote-ip:/path/to/destination_dir

To Copy Single File:

scp -r path/to/file_name.zip user@remote-ip:/path/to/destination_dir/

Replace the file extension with your own file.

Jeter-work's user avatar

answered Mar 1, 2016 at 14:44

Ramesh Chand's user avatar

WinSCP is definitely an useful utility, especially if you want a graphic interface. But if you’re looking for a command line alternative without having to deal with installing cygwin, there’s also pscp which is part of the PuTTY collection of tools.

http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

answered Oct 1, 2015 at 21:25

p_q's user avatar

if you are using windows and want to copy to the linux server then install the WINSCP and just use the drag and drop

answered Oct 15, 2015 at 9:51

aryan's user avatar

OpenSSH is available for PowerShell since 2019. Instructions for installation are available from Microsoft’s Docs site. Instructions for use of OpenSSH utilities are available on OpenSSH project site.

Basically, once you install the OpenSSH suite, scp will work as you are accustomed.

scp user@source:path/to/source/file user@destination:path/to/target/file

where source and destination are hostnames or IP addresses and a path and filename without a host name/address will be treated as local.

answered Apr 5, 2021 at 14:20

Jeter-work's user avatar

Jeter-workJeter-work

8254 silver badges15 bronze badges

SCP <path of the file along with filename and extension> <name of vm>@<ip address>:<path where file needs to be copied>

answered Dec 19, 2022 at 7:49

Aditya Fargade's user avatar

Понравилась статья? Поделить с друзьями:
  • Copy files from unix to windows
  • Copy files from linux to remote windows
  • Copy files from iphone to windows
  • Copy file from mac to windows
  • Copy con в командной строке windows