nerdexam
CompTIA

XK0-005 · Question #857

A systems administrator needs to compress log files using the .tar.bz2 format. Which of the following commands should the administrator use?

The correct answer is C. tar -cvjf logs.tar.bz2 /var/log/*. To create a tar.bz2 archive of log files, the tar command with the -c, -v, -j, and -f options is the appropriate method.

System Management

Question

A systems administrator needs to compress log files using the .tar.bz2 format. Which of the following commands should the administrator use?

Options

  • Atar -cvtf logs.car.bz2 /var/log/*
  • Btar -cvzf logs.tar.bz2 /var/log/*
  • Ctar -cvjf logs.tar.bz2 /var/log/*
  • Dtar -cvbf logs.tar.bz2 /var/log/*

How the community answered

(21 responses)
  • B
    5% (1)
  • C
    90% (19)
  • D
    5% (1)

Why each option

To create a `tar.bz2` archive of log files, the `tar` command with the `-c`, `-v`, `-j`, and `-f` options is the appropriate method.

Atar -cvtf logs.car.bz2 /var/log/*

The `-t` option lists the contents of an archive, it does not create or compress, and `logs.car.bz2` contains a typo.

Btar -cvzf logs.tar.bz2 /var/log/*

The `-z` option is used for `gzip` compression, not `bzip2` compression.

Ctar -cvjf logs.tar.bz2 /var/log/*Correct

This command correctly creates a tar archive and compresses it using bzip2. The `c` option creates a new archive, `v` provides verbose output, `j` instructs `tar` to use `bzip2` for compression, and `f` specifies the name of the output archive file (`logs.tar.bz2`). `/var/log/*` indicates the files to be included.

Dtar -cvbf logs.tar.bz2 /var/log/*

The `-b` option sets the block size for an archive and is not used for specifying a compression algorithm like bzip2.

Concept tested: Linux tar and bzip2 compression

Source: https://man7.org/linux/man-pages/man1/tar.1.html

Topics

#tar command#bzip2#file compression

Community Discussion

No community discussion yet for this question.

Full XK0-005 Practice