folder copying



I've never used scp. But from a quick look at its man-page, it doesn't look too difficult to work out.

Syntactically, your second command looks more correct than the first. It uses absolute paths for the source and target directories.

And because it uses absolute paths - the second command could be ran from anywhere in server1's file-system and it should predictably copy the specified directory from server1 to server2.

So that should recursively copy server1's /etc/yum.repos.d/ directory to the /etc/ directory on server2, using devroot@server2's user account.

Whereas the first command uses a relative path for the source and destination directories.

So the effect of running the first command would depend on where you are in server1's file-system at the time that you issue the command. The directory structure/content of the current working directory would also be a factor.

For example:
If you were in your home directory on server1 (e.g. /home/username/) when you typed the first command - it would attempt to recursively copy a sub-directory called etc/yum.repos.d/ from your home directory to server2.
If the /home/username/etc/yum.repos.d/ directory does not exist - I imagine that you'll probably get an error message.

Whereas if you issued that command from the root of the file-system / , then the etc/yum.repos.d/ (which probably does exist) will be copied to server2.

Also, in the first command - because the destination is missing the leading forward slash / (making the destination a relative path too) - I think it will attempt to copy the etc/yum.repos.d/ directory to whatever default directory the user devroot ends up in on server2 when they are logged-in (e.g. /home/devroot/ ?).

In which case - assuming that the source directory CAN be found in the current directory on server1 - you'd end up with it being copied to the /home/devroot/etc/ folder on server2.

I could be wrong, but that's how it looks to me!
 
Last edited:


Top