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'm a Linux newbie and I'm trying to zip a folder which exists on a remote host and export it to another remote host. A quick Google search lead me to tar/gzip and rsync options but I'm not sure how exactly I could use them.

To be very clear I have logged into remote host through PuTTY (SSH) user@remotehost1 and there is a folder, folder1 (/u01/folder1) which has other sub-folders and files underneath it. I want to gzip it and export it to another remote host user@remotehost2. How can I achieve this. Could some on clearly explain me.

share|improve this question

migrated from May 20 '13 at 15:31

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

You're asking two distinct questions: How to compress a folder, and how to copy a file between servers. You'll have an easier time finding the answer to questions yourself if you break them down into their component parts. – Kitsune May 20 '13 at 15:34

Compress the folder:

tar czvf folder.tgz folder

Copy to other host:

scp folder.tgz user@remotehost2:~

This command copies the folder.tgz file to the home directory of user at remotehost2.

share|improve this answer

Once you are logged on to the remote host, do:

  1. Compress the folder (this will create the archive folder.tgz)

    tar cvvzf folder.tgz /u01/folder1
  2. Copy the folder to the remote machine

    scp folder.tgz user2@remotehost2:/path/to/remote/target
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .