Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I wanna simpy exchange 3 directories to a collegue's home directory (I dont have write access to that one) from my home directory, probably using secure copy if possible. I am not good with Linux command line, so I am not sure how to do that and I would very much appreciate it if somebody could help me a bit out with this. I guess it should look something like that

scp -r /home/user1/directoy1 /home/user2/directoy1 
scp -r /home/user1/directoy2 /home/user2/directoy2 
scp -r /home/user1/directoy3 /home/user2/directoy3 

Do I need to specify the login name of my collegue so that the files can be copied when he enters his password?

Thanks for your help, Michael

share|improve this question

migrated from Mar 9 '11 at 15:53

This question came from our site for professional and enthusiast programmers.

I am not sure if this is the simplest solution, but at least this should work if only your collegue has access to the target directory.

scp -r /home/user1/directoy1 user2@localhost:/home/user2/directoy1

You could also use rsync that is more versatile tool (highly recommended):

rsync -r /home/user1/directoy1 user2@localhost:/home/user2/directoy1

If you need to synchronize files in both directions, you should use some file-synchronization tool like Unison.

share|improve this answer
Thanks for all your help, I tried as both or you suggest with the scp command but after entering the command the terminal ends up in an endless loop where nothing is happening. Is there another way to copy these files quickly and easily? – Michael Mar 9 '11 at 13:47

scp isn't a tool for copying files securely on the same host, it is a tool for copying files across network using the SSH protocol.

In your case, you can "cheat" a little, using SSH on the localhost to log you with your coworker credential, thus having the good access right :

scp -r /home/user1/directory1 username@localhost:

This will copy directory1 in your coworker's home directory. But be aware that this command will ask for your coworker's password.

A better way, if this is not a one time copy, is to set the rights on the directories so you can write in it, or using a shared directory for file transfers.

share|improve this answer
It is also a tool for doing local-local copies (even though it isn't any more useful than ordinary cp). – grawity Mar 9 '11 at 19:06

You must log in to answer this question.