Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 worked, how to set the hard disk from where I copy my files?

share|improve this question

5 Answers 5

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.

share|improve this answer

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@
  • scp - secure copy command
  • file.txt - file you want to copy
  • root - username used to log onto CentOS machine
  • - 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@

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

share|improve this answer

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

share|improve this answer

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

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.