Tar and Zip Compression

LinuxLinuxBeginner
Practice Now

Introduction

In this challenge, you need to compression files and directories. You will use the tar and zip commands.

Achievements

  • tar - Create, extract, and list files from a tar archive
  • zip - Compress files

Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/CompressionandArchivingGroup(["`Compression and Archiving`"]) linux/CompressionandArchivingGroup -.-> linux/tar("`Archiving`") linux/CompressionandArchivingGroup -.-> linux/zip("`Compressing`") subgraph Lab Skills linux/tar -.-> lab-27{{"`Tar and Zip Compression`"}} linux/zip -.-> lab-27{{"`Tar and Zip Compression`"}} end

Packing Files

In this challenge, you need to pack files with the tar command.

We have already created three files for you, file1, file2, and file3. You can find them in the /home/labex/project directory.

Tasks

  • You need to pack the file1, file2, and file3 files into different archive files.

Requirements

  • You must use the tar command to pack files and directories.
  • You must pack files with the gzip, bzip2, and xz compression methods.
  • Don't change the file name and path of the archive file.

Example

After you have packed the files, you can use the ls command to list the files in the /home/labex/project directory. You should see the following output:

cd ~/project
ls
archive.tar.bz2  archive.tar.gz  archive.tar.xz

Zip Files

In this step, you need to pack files with the zip command.

Tasks

  • You need to pack the file1, file2, and file3 files into archive.zip.

Requirements

  • You must use the zip command to pack files and directories.
  • You must include the file1, file2, and file3 files in the archive.zip file.
  • You need to use quiet mode when packing files.
  • Don't change the file name and path of the archive file.

Example

After you have packed the files, you can use the ls command to list the files in the /home/labex/project directory. You should see the following output:

cd ~/project
ls
archive.zip

Summary

In this challenge, you learned how to packing and unpacking files using the tar command and you also learned how to compress files using the zip commands.

Other Linux Tutorials you may like