Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Using scp command I want to move files from local system to a remote system. I'm doing something like this:

$ scp file1 root@abc:root /root/tmp

With this command I'm able to upload file1 to abc:/root, but the problem is that it changes the names to tmp like in my case, I want to keep the name the same as the original and just copy it to the folder.

How can I do this?

share|improve this question

4 Answers 4

up vote 1 down vote accepted

Do this:

$ scp file1 root@abc:/root/tmp/

This would also work:

$ scp file1 root@abc:~/tmp/

If the directory /root/tmp isn't on the remote system abc, you can do this, and rsync will create the remote directory for you:

$ rsync -ave ssh file1 root@abc:/root/tmp

Lastly if you have to use ssh you can do this:

$ cat file1 | ssh root@abc "mkdir /root/tmp; cat >> /root/tmp/file1"
share|improve this answer

This means that the /root directory on abc does not contain a tmp sub-directory. One more thing: you're using an extra root in your command line. (It should be scp file1 root@abc:/root/tmp)

Here's what you should do:

  • First create the required sub-directory on abc:

    ssh root@abc 'mkdir /root/tmp'
    
  • Then copy the file into the newly-created sub-directory:

    scp file1 root@abc:/root/tmp
    
share|improve this answer

Just omit the final parameter, and the copied file will be /root/file1

scp file1 root@abc:root
share|improve this answer
    
but i want to place the FILE in root/tmp folder –  asadz Jul 10 '13 at 22:10

When a destination is not followed by a slash, it is interpreted as a new name for the file unless that folder already exists. So either:

$ scp file1 root@abc:root /root/tmp/

Or create the /root/tmp/ directory, then:

$ scp file1 root@abc:root /root/tmp
share|improve this answer

Your Answer

 
discard

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.