What flag is used with tar to create a compressed archive?

Disable ads (and more) with a premium pass for a one time $4.99 payment

Boost your Linux skills with the CompTIA Linux+ Certification Exam simulator. Engage with multiple choice questions and detailed feedback. Master Linux concepts and prepare for your exam with confidence!

The flag used with tar to create a compressed archive is -z. This flag instructs the tar command to use gzip compression when creating the archive. When you append the -z flag to the tar command along with the -c flag (which indicates that you want to create an archive), the resulting archive will be compressed using gzip, resulting in a smaller file size compared to an uncompressed archive.

In practice, a command that creates a compressed tar archive would look like this: tar -czf archive.tar.gz file1 file2, where the -c flag indicates creation, -z specifies gzip compression, and -f indicates the filename for the archive being created.

The use of -j, on the other hand, would suggest the use of bzip2 compression instead of gzip, which is another valid option but not the one in focus for this question. The flag -c is indeed essential for creating an archive but does not indicate compression. Lastly, the -f flag is used to specify the filename of the archive being created. Therefore, for creating a compressed archive, -z is the correct flag to use with tar.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy