zip Command: Tutorial & Examples
Compress files
The zip command
in Linux is a command-line utility that is used to create, modify, and extract archive files in the ZIP format. The basic syntax for creating a zip archive
is zip [options] archive_name file1 file2 file3...
When you run the zip
command followed by an archive name and a list of files or directories, it will create a new archive file with the specified name and compress the specified
files or directories into that archive.
For example, if you want to create a zip archive of the files file1.txt
, file2.txt
, and file3.txt
and name it archive.zip
, the command would
be zip archive.zip file1.txt file2.txt file3.txt
The zip
command also has several options that can be used to modify the behavior of the command, such as:
-r
option to recursively compress all files in a directory-9
option to compress files using maximum compression level-u
option to update an existing archive-d
option to delete files from an archive-v
option to display the progress of the compression
The unzip
command can be used to extract archive files in the ZIP format. zip
and unzip
are commonly used to compress and
extract files on Linux systems, they are widely supported and can be used to compress and extract files in a cross-platform manner.