How To: Extract .tar.gz archives remotely via SSH

Earlier this week, I downloaded some script I wanted to try out as a .tar.gz file, extracted it to my computer then set my FTP client to upload everything to the web server.  Half an hour later, I came back and it was still going.  Given that Dreamhost gives me SSH access to the server, this is what I should’ve done in the first place, and when I realised it, it took about a minute to get all the extracted files up there.

  1. Upload the .tar.gz file to the server using an FTP program (or use SSH to download them straight to the server).
  2. Connect to the server via SSH, for example using PuTTY.
  3. Use the following command to extract, where your file is called file.tar.gz:
    tar zxf file.tar.gz
  4. That’s it! You can then delete the archive file and move around the extracted files using either the shell commands (e.g. rm file.tar.gz to delete the archive)

This is by far the easiest way to go about uploading a script to your web server, if you have this facility.

The command contained three parameters, zxf, which were passed to the tar program, these have the following function:

  • x - extract
  • z - it’s gzipped (so omit the z if you merely have a .tar file)
  • f - supplying filename on command line.

0 Responses to “How To: Extract .tar.gz archives remotely via SSH”


  1. No Comments