Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I compress the contents of a folder using the tar command on an Unix system over SSH?

share|improve this question

migrated from stackoverflow.com May 21 '11 at 20:08

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

    
Sounds like a question for Server Fault (serverfault.com) –  RonK May 21 '11 at 20:07
    
@RonK: Could you explain why? Because it sure doesn't belong there... –  Tom Wijsman May 21 '11 at 21:32
    
Because that is where I post such questions :-) . Any way - this comment was added before the question was migrated. –  RonK May 22 '11 at 5:08

3 Answers 3

From tar --help:

Examples:
  tar -cf archive.tar foo bar  # Create archive.tar from files foo and bar.
  tar -tvf archive.tar         # List all files in archive.tar verbosely.
  tar -xf archive.tar          # Extract all files from archive.tar.

So just use tar -cf archiveName.tar folderName.

share|improve this answer

If you want to compress it, add the -z or -j arguments to the recommendations above.

ssh user@host 'tar -C direcotry -czf archivename.tar.gz files/directory'
share|improve this answer

If the content you want to archive is in the home directory of the user - it should be:

ssh login_name@hostname 'tar cvf archive-name *'

If you need to navigate somewhere, try this:

ssh login_name@hostname 'cd some-dir;tar cvf archive-name *'
share|improve this answer

Your Answer

 
discard

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