Blog / Others/ How to Install Unzip on Linux VPS to Extract ZIP Files (Debian/CentOS)

How to Install Unzip on Linux VPS to Extract ZIP Files (Debian/CentOS)

Problem Background

When working on a Linux VPS, you often need to extract ZIP archive files. Many CentOS-based LNMP environments may include the unzip command by default. However, on Debian-based systems (such as when setting up an LLsMP environment), you might encounter a "command not found" error when trying to run unzip after uploading a ZIP file. This indicates the unzip utility is not installed by default.

Generally, Linux systems tend to support .gz or .tar.gz archives natively, while ZIP format support requires manual installation of the appropriate extraction tools.

Installation Method

The installation process is straightforward. Use the package manager command corresponding to your Linux distribution.

1. Debian / Ubuntu Systems

If you are using Debian, Ubuntu, or a derivative, connect to your VPS via SSH and run the following commands:

apt-get update
apt-get install -y zip unzip

Explanation:

  • apt-get update: Updates the package list to ensure you install the latest versions.
  • apt-get install -y zip unzip: The -y flag automatically confirms the installation. This command installs both the zip (compression) and unzip (extraction) components.

2. CentOS / RHEL / Fedora Systems

If you are using CentOS, Red Hat Enterprise Linux (RHEL), or Fedora, execute the following command via SSH:

yum install -y zip unzip

For newer versions (CentOS 8+/RHEL 8+) that use the dnf package manager, you can use:

dnf install -y zip unzip

Explanation:

  • yum install -y zip unzip: The -y flag serves the same purpose, auto-confirming the installation via the YUM package manager.

Verifying Installation

After installation, verify that unzip is installed correctly with either of these commands:

unzip -v

or

which unzip

If the command returns version information or the path to the unzip binary, the installation was successful.

Basic Usage Examples

Once installed, you can use the unzip command to extract files.

# Extract to the current directory
unzip yourfile.zip

# Extract to a specific directory
unzip yourfile.zip -d /path/to/target/directory

# List contents of a ZIP file without extracting
unzip -l yourfile.zip

You have now successfully installed the ZIP extraction tool on your Linux VPS and can conveniently manage ZIP format archives.

Post a Comment

Your email will not be published. Required fields are marked with *.