XK0-004 · Question #499
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?
The correct answer is B. tar cvfz ./user.tar.gz /home/user. The tar command requires specific flags to create a gzip-compressed archive. The correct flag order and compression option must match the intended output file format.
Question
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?
Options
- Atar xvfz /home/user user.tar.z
- Btar cvfz ./user.tar.gz /home/user
- Ctar cvfx user.tar.zip /home/user
- Dtar xfvZ user.tar.Z ./home/user
How the community answered
(54 responses)- A2% (1)
- B93% (50)
- C4% (2)
- D2% (1)
Why each option
The tar command requires specific flags to create a gzip-compressed archive. The correct flag order and compression option must match the intended output file format.
The 'x' flag extracts an archive rather than creating one, making this command attempt to decompress rather than compress.
The 'c' flag creates a new archive, 'v' enables verbose output, 'f' specifies the output filename, and 'z' applies gzip compression - all required to produce a .tar.gz file. The destination archive path comes before the source directory, which is the correct tar syntax for creation. This command will recursively archive and compress all contents of /home/user into ./user.tar.gz.
The 'x' flag again specifies extraction, and tar has no native 'zip' compression flag - .zip is not a valid tar compression format.
The 'x' flag specifies extraction, 'Z' denotes compress (legacy .Z format) not gzip, and the argument order places the source path after the archive name which is incorrect for creation.
Concept tested: Linux tar archive creation with gzip compression
Source: https://man7.org/linux/man-pages/man1/tar.1.html
Topics
Community Discussion
No community discussion yet for this question.