How to: tar a file, gzip a file, untar a file

I thought I’d share incase anybody else runs into the problem and needs to tar or gzip a file on their server.

How to tar and then how to gzip (compress) a file in SSH
When you are logged into SSH this command line should tar and then gzip your folder into a .tar.gz file. This will gzip your file into the current directory:
tar -czf whatever.tar.gz foldername
If you’d like to tar your file and have it put in another location use this:
tar -czf /directory/directory/whatever.tar.gz foldername

How to untar and how to ungzip (or unzip) a file in SSH:
This will untar and uncompress your file, then it will place that folder in the directory you are currently in restoring your old folder and file structure:
gunzip -dc whatever.tar.gz | tar xvf -

Thank you, and good night.

4 Responses to “How to: tar a file, gzip a file, untar a file”


  1. 1 Athan

    thanks. this helped!

  2. 2 Smoother

    Thanks for stopping by and I’m glad this helped you out Athan.

  3. 3 Moataz Almadawy

    thanks man great pos

  4. 4 TA

    Thanks a lot, this is near the top when you google “how to tar” and so will help a lot of people…

Leave a Reply