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 command is tar -czvf system_logs.tar.gz /var/log. The -c option tells tar to create a new archive, -z instructs it to compress the archive with gzip, -v enables verbose output to show the files being processed, and -f specifies the filename of the archive. One incorrect option omits the -z flag, which means the archive would be created but not compressed with gzip. Another incorrect option uses -r, which is for appending files to an existing archive, not creating a new one. The final incorrect option uses improper syntax; the -f flag requires the output filename to be its next argument, but here it is followed by the source directory, and it incorrectly attempts to combine this with stdout redirection.
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 different options in the tar command mean?
Open an interactive chat with Bash
Why is gzip compression used in the tar command?
Open an interactive chat with Bash
What happens if you use the wrong options with the tar command?