Prerequisites :

  1. Basic familiarity with using the Linux terminal.
  2. Access to a Linux-based operating system.

Step 1: Compression with gzip:

gzip is a popular compression tool on Linux.

To compress a file using gzip, use the following command:

gzip filename

Replace filename with the name of the file you want to compress. This will create a compressed file with a .gz extension.

Step 2: Compression with zip:

zip is another common compression tool that can create zip archives.

To create a zip archive, use the following command:

zip archive_name.zip files_to_compress

Replace archive_name.zip with the desired name for your zip file and files_to_compress with the names of the files you want to include in the zip archive.

Step 3: Decompression with gzip: To decompress a file compressed with gzip, you can use the gunzip command or simply gzip -d.

gunzip filename.gz

or

gzip -d filename.gz

This will decompress the file and remove the .gz extension.

Step 4: Decompression with zip:

To decompress a zip archive, you can use the unzip command.

unzip archive_name.zip

This will extract the contents of the zip archive into the current directory.

File compression and decompression are essential skills for managing files on Linux systems. With the gzip and zip commands, you can easily compress and decompress files and directories directly from the terminal. Practice using these commands with different files to become comfortable with file compression and decompression on Linux.