- 8777701917
- info@saikatinfotech.com
- Basirhat W.B
gzip (GNU Zip) is a popular compression tool in Linux (and Unix-like systems) used to reduce the size of files. It is primarily used for file compression, and it’s known for its efficiency and fast compression speed. It only compresses individual files, not directories, but it is commonly used in combination with other tools like tar to archive and compress entire directories.
gzip:.gz files.gzip is fast, making it ideal for quickly reducing file sizes.
Creating a compressed archive using tar and gzip:
c: Create a new archivez: Compress using gzipv: Verbose (lists files being archived)f: Specify the file name (archive_name.tar.gz)tar.gz archive:x: Extract the archivez: Decompress using gzipv: Verbose (lists files being extracted)f: Specify the archive file namgzip:gzip provides good compression ratios, reducing file size effectively.gzip:gzip works on individual files, so if you need to compress multiple files or entire directories, you must combine it with tools like tar..zip), gzip does not have built-in support for encryption or password protection.gzip:.gz: The most common extension used for files compressed with gzip..tar.gz or .tgz: A compressed archive created by using tar to bundle files, followed by gzip compression.gzip is a file compression tool in Linux that is primarily used to reduce the size of individual files. It is fast and efficient but doesn’t handle directories on its own. It is often used in conjunction with tar to archive and compress multiple files or directories.
Notes- Only for Use Gzip file type not Use directory
Linux create tar.gz file with tar command
tar -czvf filename.tar.gz /path/to/dir1
tar -czvf filename.tar.gz /path/to/dir1 dir2 file1 file2
-c is creating and archive.
-z is using gzip compression.
-v is providing details of the files that have been archived.
-f is creating an archive with the name ‘logs_archive.tar.gz’ as supplied in the command above.
How to extract a tar.gz compressed archive on Linux
tar -xvf file.tar.gz
tar -xzvf file.tar.gz
tar -xzvf projects.tar.gz
-x is extracting and archive.
-z specifies that the archive is gzip.
-v is providing details of the files that have been archived.
-f is extracting from the archive named ‘logs_archive.tar.gz
How to view the contents of an archive
tar -tvf logs_archive.tar.gz
File.gz File View commnd
zcat file.gz
Zip file View without extarct Commnd
zipinfo file.zip
Use the Most Common zip Command Options
The following are the most common zip command options:
How to create multiplefile touch commend ?
touch filename{1..10}.txt
How to create tar file ?
tar cvf <filename>.tar <filename> then enter
How to create tar file untar ?
tar xvf <filename>.tar <filename> then enter
tar –xvzf <filename>.tar <filename> then enter
How to create compress reduce size tar file ?
tar cjf <filename>.tar.gz cvf <filename> then enter
How to create gzip ?
gzip <filename>
How to create gzip extarct ?
gunzip <filename>
zcat <filename>
How to create bzip2 ?
bzip2 <filename>
How to create bzip2 extarct ?
bunzip2 <filename>
How to view file size check ?
du -sh <filename>
The Zip command in Linux is a powerful utility that compresses files and directories into a single archive file using the .zip format. Compressing files reduces the size and helps to pack multiple files together for faster data transfer or storage. Many operating systems, such as Windows, macOS, Linux, and Unix support the Zip format, allowing you to pack and extract files across major platforms.
The zip command in Linux is used to archive and compress files into a single .zip file. It combines multiple files and directories into one file while compressing them to reduce the overall size. zip is widely used across different platforms (including Windows, Linux, and macOS), making it a convenient choice for cross-platform file sharing.
zip Command:zip compresses files and archives them into a .zip file, making it convenient for file storage and transfer..zip files can be opened on most operating systems, including Linux, Windows, and macOS, using native tools (like WinRAR on Windows or the built-in unzip command on Linux).
ommon zip Command Options
The following are the most common zip command options:
| Option | Description |
|---|---|
-r | Recursively compress directories and their contents. |
-j | Junk (omit) directory names from the Zip archive. |
-m | Move the specified files into the Zip archive (delete files after zipping). |
-u | Update existing entries in the Zip archive with newer versions. |
-d | Delete entries from the Zip archive. |
-x | Exclude specific files or patterns from being zipped. |
-q | Quiet mode, suppress output messages for less verbosity. |
-v | Verbose mode, display detailed output during the compression process. |
-9 | Use the best compression method to maximize file size reduction. |
-e | Encrypt the Zip archive with a password for added security. |
Compress the dir directory and all its contents including
sub-directories into archive.zip.
zip -r archive.zip dir/
Delete specific files, such as file1.txt from the archive.zip
zip -d archive.zip file1.txt