How to compress a directory in Linux?
To compress a directory into a compressed file, you can use the following command:
- Create a compressed archive of a directory using the command: tar -cvf archive.tar directory_name
- Tar is a command used for compressing files or directories.
- 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.
- The filename after packaging is archive.tar.
- The directory_name is the name of the directory to be packaged.
- Compressing and packaging files: gzip archive.tar.
- gzip is a command used to compress files.
- 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.