How to compress a directory in Linux?

To compress a directory into a compressed file, you can use the following command:

  1. Create a compressed archive of a directory using the command: tar -cvf archive.tar directory_name
  2. Tar is a command used for compressing files or directories.
  3. The option parameters for cvf are: c for creating a new compressed file, v for displaying detailed information, and f for specifying the file name.
  4. The filename after packaging is archive.tar.
  5. The directory_name is the name of the directory to be packaged.
  6. Compressing and packaging files: gzip archive.tar.
  7. gzip is a command used to compress files.
  8. The file name to compress is archive.tar

The command above will create a compressed file named archive.tar.gz in the current directory, which contains the contents of the directory to be packed.

bannerAds