There are several tools for compressing and decompressing files in Linux, you can get a summary of these tools in this link. Zip is one of the utilities used for packaging, compressing (archive) and decompressing files.
sudo apt-get update
sudo apt-get install zip unzip
sudo yum install unzip
Compress files in a directory named tutorial –
$ zip -r tutorial.zip tutorial/
adding: tutorial/ (stored 0%)
adding: tutorial/host.conf (deflated 13%)
adding: tutorial/hostname (stored 0%)
adding: tutorial/hosts.deny (deflated 44%)
adding: tutorial/hosts (deflated 35%)
adding: tutorial/hosts.allow (deflated 42%)
adding: tutorial/auth_sa.py (deflated 52%)
Start writing or type / to choose a block
$ zip -sf tutorial
Archive contains:
tutorial/
tutorial/host.conf
tutorial/hostname
tutorial/hosts.deny
tutorial/hosts
tutorial/hosts.allow
tutorial/auth_sa.py
Total 7 entries (2487 bytes)
View contents of zip files, without uncompressing –
Start writing or type / to choose a block
To decompress a zipped file, use the unzip command –
$ unzip tutorial.zip
Archive: tutorial.zip
creating: tutorial/
inflating: tutorial/host.conf
extracting: tutorial/hostname
inflating: tutorial/hosts.deny
inflating: tutorial/hosts
inflating: tutorial/hosts.allow
inflating: tutorial/auth_sa.py
You can also combine find and zip command to search for certain types of files and compress those files in one command -Code
$ find . -type f -name '*.conf' -print | zip confi-files -@
adding: host.conf (deflated 13%)
adding: colord.conf (deflated 50%)
adding: ntp.conf (deflated 56%)
$ zip -sf confi-files
Archive contains:
host.conf
colord.conf
ntp.conf
Total 3 entries (1858 bytes)
References -
https://linux.die.net/man/1/zip
Linux System Admins Journey to Google Cloud Platform As a Linux system administrator, you have…
As a network professional, troubleshooting is a crucial part of your daily routine. To streamline…
The net-tools set of packages had been deprecated years back, although the commands are still…
Re-posting my answer to a Google cloud platform's Google Kubernetes Engine (GKE) related question in…
Recently I was trying to download numerous files from a certain website using a shell…