Hostxpeed
Login Get Started →
Getting Started

How to Unzip Files on VPS

5 min read
22 views
Jun 12, 2026

Prerequisites

Before extracting files, make sure you have:

  • SSH access to your VPS
  • Compressed file on your server
  • Sufficient disk space for extracted contents

Method 1: Extract ZIP Files

Connect to your VPS:

ssh hxroot@YOUR_SERVER_IP -p 22

Install unzip if needed:

apt install unzip -y

Extract ZIP file:

unzip file.zip

Extract to specific directory:

unzip file.zip -d /target/directory/

List contents without extracting:

unzip -l file.zip

Extract specific file:

unzip file.zip specific-file.txt

Overwrite files without prompting:

unzip -o file.zip

Exclude files/directories:

unzip file.zip -x "*.log"

Method 2: Extract TAR Files

Extract .tar:

tar -xf file.tar

Extract .tar.gz or .tgz:

tar -xzf file.tar.gz

Extract .tar.bz2:

tar -xjf file.tar.bz2

Extract .tar.xz:

tar -xJf file.tar.xz

Extract to specific directory:

tar -xzf file.tar.gz -C /target/directory/

Verbose output (show extracted files):

tar -xvzf file.tar.gz

List contents without extracting:

tar -tzf file.tar.gz

Method 3: Extract GZIP Files (.gz)

Extract .gz file (removes .gz after extraction):

gunzip file.gz

Keep original .gz file:

gunzip -c file.gz > extracted_file

Using gzip:

gzip -d file.gz

Method 4: Extract BZIP2 Files (.bz2)

bunzip2 file.bz2

Or:

bzip2 -d file.bz2

Method 5: Extract RAR Files

Install unrar:

apt install unrar -y

Extract:

unrar x file.rar

List contents:

unrar l file.rar

Method 6: Extract 7-Zip Files (.7z)

Install p7zip:

apt install p7zip-full -y

Extract:

7z x file.7z

Extract to specific directory:

7z x file.7z -o/target/directory/

Quick Reference Table

File TypeCommand
.zipunzip file.zip
.tartar -xf file.tar
.tar.gz / .tgztar -xzf file.tar.gz
.tar.bz2tar -xjf file.tar.bz2
.tar.xztar -xJf file.tar.xz
.gzgunzip file.gz
.bz2bunzip2 file.bz2
.rarunrar x file.rar
.7z7z x file.7z

Extract Password-Protected ZIP

unzip -P password file.zip

Or prompt for password:

unzip -e file.zip

Split Archives

Extract multi-part ZIP:

zip -s 50M large_folder -r split.zip
# Then extract all parts
unzip "split.z*"

Extract multi-part RAR (.part1.rar, .part2.rar, etc.):

unrar x file.part1.rar

Script to Extract Multiple Archives

#!/bin/bash
for file in *.zip; do
    echo "Extracting $file..."
    unzip -o "$file" -d "${file%.zip}"
done

Check Archive Integrity

Test ZIP file:

unzip -t file.zip

Test TAR.GZ:

gunzip -t file.tar.gz

✅ You can now extract various compressed file formats on your Hostxpeed VPS.

Was this article helpful?