Zipping and unzipping files using SSH

  1. SSH into your server
  2. Install zip and unzip.
    1. CentOS / Fedora / Red Hat: yum install zip and yum install unzip
    2. Debian / Ubuntu: apt-get install zip and apt-get install unzip
  3. Zip a file: zip new-zip-file.zip file-to-zip
  4. Zip all files in directory: zip new-zip-file.zip *
  5. Zip a directory: zip -r new-zip-file.zip directory-to-zip
  6. Unzip to the current directory: unzip file-to-unzip.zip
  7. Unzip to a specified directory: unzip file-to-unzip.zip -d /directory-to-unzip-to
  8. List all files in the zip: unzip -l file-to-unzip.zip

Leave a Reply

Your email address will not be published.