CompTIA Linux+ (XK0-006) — Question 2
A Linux systems administrator needs to extract the contents of a file named /home/dev/web.bkp to the /var/www/html/ directory. Which of the following commands should the administrator use?
Answer options
- A. cd /var/www/html/ && gzip -c /home/dev/web.bkp | tar xf -
- B. pushd /var/www/html/ $ cpio -idv < /home/dev/web.bkp && popd
- C. tar -c -f /home/dev/web.bkp /var/www/html/
- D. unzip -c /home/dev/web.bkp /var/www/html/
Correct answer: B
Explanation
The correct answer is B because it uses the cpio command to extract the contents of the web.bkp file into the specified directory. Option A is incorrect as it is using gzip and tar inappropriately for extraction. Option C is incorrect because it attempts to create a new archive instead of extracting. Option D is wrong since it uses unzip, which is not suitable for handling tar or cpio archives.