How to zip and unzip files and folders on your remote server

When installing, lets say, a WordPress, you naturally need to move the files to the server. It's about ~100 times faster to move one big compressed file than a folder containing literally thousands of small files. But, you can't unzip anything from your FTP client. Here's all about zipping and unzipping.

Ideally you have an SSH access to your server (SSH means Secure shell, read more about it). Meaning that you log into your server using the Terminal (Mac) or Putty if your on Windows. If you don’t have SSH access, don’t worry, there is another way.

Login with SSH

If you’re not sure how to login, here’s how that happens:

ssh username@domainname.com

// Or using an IP
ssh username@12.12.12.123

// Or if custom post is defined
ssh -p 5555 username@domainname.com

See article on SSH keys and easy logins.

Zip

There’s many packaging algorithms, zip is one of them. It has .zip file extension.

Compress a folder using zip

$ zip -r archive.zip foldername
  • -r include all files and directories
  • archive.zip name of the zip file you want to do
  • foldername name of the folder you want to zip

If you don’t have zip installed, in Ubuntu and Debian it can be installed with apt-get:

$ sudo apt-get install zip

Decompress with zip

$ unzip archive.zip

Gzip

This post looks into the GNU tar application to do Gzipping. GNU tar supports both archive compressing through gzip and bzip2.

It’s very similar to Zip, but is more effective. Gzip files have .tar.gz or .tgz extension, and are usually called tarballs.

Compressing with Gzip

Gzip has a ton of option. Here’s the basic command:

$ tar -zcvf compressed-file.tar.gz /directory/needing/compression

Decompressing with Gzip

$ tar -zxvf compressed-file.tar.gz

Unzipping using a PHP script

I’ve been using this script PHP Unzipper. Just unzip it and throw to your server and navigate to yourdomain.com/index2.php

Or you can use some other script, like this. I haven’t tested it.

Comments

Club-Mate, the beverage → club-mate.fi