CompTIA Linux+ (XK0-004) — Question 301
A technician wants to archive and compress all files and folders contained within the /home/user directory.
Which of the following commands should the technician execute?
Answer options
- A. tar xvfz /home/user user.tar.z
- B. tar cvfz ./user.tar.gz /home/user
- C. tar cvfx user.tar.zip /home/user
- D. tar xfvZ user.tar.Z ./home/user
Correct answer: B
Explanation
The correct command is B because it uses 'tar' with the 'c' (create), 'v' (verbose), 'f' (file), and 'z' (gzip) options, which are suitable for archiving and compressing the contents of the /home/user directory into a .tar.gz file. Option A is incorrect as it attempts to extract files rather than create an archive, while option C uses the wrong compression format (zip instead of gzip), and option D also tries to extract rather than create an archive.