Which command is used to create a compressed archive of a directory?

Prepare for the LPIC-2 Certification Test with our study tools, including flashcards and multiple choice questions with hints and explanations. Get ready to pass your exam!

The command that creates a compressed archive of a directory is indeed the one using the tar utility, specifically with the -czf options. This command performs multiple functions: it creates an archive, compresses it using gzip, and specifies the output file name.

When examining this command, tar serves as a versatile tool in Linux for archiving files and directories. The options used have the following purposes:

  • c stands for "create", indicating that a new archive is to be made.

  • z tells tar to compress the archive using gzip.

  • f indicates that the next argument will be the name of the archive file to be created.

The resulting file, typically with a .tar.gz extension, is a single archive file that contains all the contents of the specified directory, compressing the data to save space.

While the command using zip would also create a compressed archive, it is primarily intended for compressing individual files or sets of files rather than handling directories unless paired with the -r option, which recursively includes all files and directories under the specified directory. However, this method is less commonly used for complete backups compared to tar.

The gzip command

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy