Zipping and Unzipping Files under Linux

Asked by Yamir via e-mail

Question: MS-Windows has winzip program. I cannot find anything under Application menu to zip or unzip files on Linux. I am using Debian Linux. How do I zip and unzip file under Linux operating systems?

Answer: Linux has both zip and unzip program. By default, these utilities are not installed. You can install zip/unzip tools from the shell prompt. Open the Terminal by clicking on Application > System Tools > Terminal. You must be a root user, Type the following two commands to install zip and unzip program on Debian or Ubuntu Linux:

# apt-get install zip
# apt-get install unzip

OR
$ sudo apt-get install zip unzip
If you are Red Hat Linux/Fedora/CentOS Linux user then you can use the yum command to install zip and unzip program as follows:

# yum install zip
# yum install unzip
  • zip is a compression and file packaging utility for Linux and Unix (including FreeBSD, Solaris etc).
  • unzip will list, test, or extract files from a ZIP archive files.

ziping files/directories examples

Creates the archive data.zip and puts all the files in the current directory in it in compressed form, type:

$ zip data *

Note: No need to add .zip extension or suffix as it is added automatically by zip command.
Use the ls command to verify new zip file:
$ ls
To zip up an entire directory (including all subdirectories), type the following command:

$  zip -r data *

unziping files/directories examples

To use unzip to extract all files of the archive pics.zip into the current directory & subdirectories:

$ unzip  pics.zip

You can also test pics.zip, printing only a summary message indicating whether the archive is OK or not:

$ unzip -tq pics.zip

To extract the file called cv.doc from pics.zip:

$ unzip pics.zip  cv.doc

To extract all files into the /tmp directory:

$ unzip pics.zip  -d /tmp

To list all files from pics.zip:

$ unzip -l pics.zip

Linux GUI packages

You can use the following graphics packages

(1) KDE Desktop: Ark is an Archive Manager for the KDE Desktop. You can start Ark from Application > Accessories.

(2)GNOME Desktop: File Roller ia an Archive Manager for the GNOME Desktop.

See also

For more information please consult the following resources:

🐧 If you liked this page, please support my work on Patreon or with a donation.
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
26 comments… add one
  • Ari Feb 2, 2016 @ 8:43

    Still, can’t use it..

  • Salem Nov 22, 2015 @ 11:56

    it’s like many people facing issue archiving their files on linux .
    in shor zip and unzip command not provided with linux distrbutions by dfualt .
    so we need to use tar command instead .:-
    BTW tar defualt stting not zipping file but put it on one uncompressed file with .tar extention .
    to compress with tar
    tar -czf ~/backup-archive.tar.gz ~/backup/
    ~/backup/ is the targit directory
    to uncompress on current directory
    tar – ~/backup-archive.tar.gz
    To uncmpress to specified directory
    tar -xzvf ~/backup-archive.tar.gz -C /target/directory

    This is best way compress uncompress on linux command line .

Leave a Reply

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

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.