During your routine system maintenance, you need to create an archive of the /var/log directory to preserve the system logs before clearing them for the new fiscal year. You decide to use the tar command to create a compressed archive. Which of the following commands correctly creates a gzip compressed archive of the /var/log directory named system_logs.tar.gz?
The correct answer is tar -czvf system_logs.tar.gz /var/log. The -c option tells tar to create a new archive, -z instructs tar to compress the archive with gzip, -v enables verbose output, displaying files added to the archive, and -f specifies the filename of the archive. The incorrect options either omit compression with gzip by not using -z, use the r option inappropriately (which is used for appending files to an already existing archive), or incorrectly specify the output archive name without the -f option which is necessary for naming the archive file.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What do the options -c, -z, -v, and -f mean in the tar command?
Open an interactive chat with Bash
What is the difference between gzip and tar?
Open an interactive chat with Bash
What are some common mistakes to avoid when using the tar command?