How to use Linux zip command to compress or decompress files?

Linux system with some powerful command tools, the zip command is one of its. Wen can use Linux zip command to compress or decompress files on Linux/Unix/Mac system.

Every Linux command tools has its unique usage with some parameters. This article will show you how to use zip command to compress or decompress documents.

The zip command is a widely used compression tool. The files are compressed to produce a compressed file with a “.zip” extension. Look the grammer and parameters to use it.

The grammar of zip command

Zip [- AcdDfFghjJKlLmoqrSTuvVwXyz$ ][- b <working directory>][- ll ][- n <suffix string>][- t <datetime>][-<compression efficiency>][compressed file][file. ..][- i <template style>][- x <template style>]

Parameters :

  • -A Adjusts the executable auto-decompressed file.
  • -b<working directory> Specifies the directory where files are temporarily stored.
  • -c Annotate each compressed file.
  • -d Deletes the specified file from the compressed file.
  • The directory name is not created in the -D compressed file.
  • -f This parameter has the same effect as specifying the “-u” parameter, but not only updates existing files. If some files do not exist in the compressed file, this parameter will be added to the compressed file.
  • -F Try to repair a corrupted compressed file.
  • -g Compresses the file and appends it to the existing compressed file instead of creating a new compressed file.
  • -h Online help.
  • -i<template style> Only compresses files that match the criteria.
  • -j saves only the file name and its contents, not any directory names.
  • -J Deletes unnecessary data before the compressed file.
  • -k Use the file name in MS-DOS compatible format.
  • -l When compressing a file, replace the LF character with the LF+CR character.
  • -ll When replacing a file, replace the LF+CR character with the LF character.
  • -L Displays copyright information.
  • -m After compressing the file and adding it to the compressed file, delete the original file, ie move the file to the compressed file.
  • -n<suffix string> Does not compress files with a specific suffix string.
  • -o Sets the change time of the compressed file to be the same as the file with the latest change time in the compressed file.
  • -q Does not display the instruction execution process.
  • -r Recursive processing, processing all files and subdirectories under the specified directory.
  • -S Contains system and hidden files.
  • -t<datetime> Sets the date of the compressed file to the specified date.
  • -T Check that each file in the backup file is correct.
  • -u Replace the newer file with the compressed file.
  • -v Displays the instruction execution process or displays version information.
  • -V Saves the file attributes of the VMS operating system.
  • -w In the file name, if the version number, this parameter is valid only under the VMS operating system.
  • -x<template style> Excludes eligible files when compressing.
  • -X does not save extra file attributes.
  • -y Saves the symbolic link directly, not the file pointed to by the connection. This parameter is valid only for systems such as UNIX.
  • -z Appends a comment to the compressed file.
  • -$ Saves the volume name of the disk where the first compressed file is located.
  • – <Compression efficiency> The compression efficiency is a value between 1 and 9.


Using the following command to package all files and folders in the /home/html/ directory to the in the current directory:

Zip - q - r html . zip / home / html 

If we are in the /home/html directory, we can execute the following command:

Zip - q - r html . zip *

Delete the file ac from the compressed file

Zip - dv cp . zip a . c

Leave a Comment