4. You run tar -cvzf archive.tar.gz folder/ but get an error. What is the likely cause?
medium
A. The order of flags is incorrect; -z must come before -c
B. The folder/ directory does not exist
C. The -f flag must be last and followed by the filename
D. You cannot combine -v and -z flags
Solution
Step 1: Verify command syntax
The flags -c (create), -v (verbose), -z (gzip), -f archive.tar.gz are correct, with filename immediately after -f.
Step 2: Determine error cause
The syntax is valid, so the likely cause is that folder/ does not exist, causing a "Cannot stat: No such file or directory" error.
Final Answer:
The folder/ directory does not exist -> Option B
Quick Check:
tar create error = missing source directory [OK]
Hint: tar create errors usually from missing source files/directories [OK]
Common Mistakes:
Assuming flag order syntax error
Overlooking if source directory exists
Confusing with permission issues
5. You want to create a compressed archive of the project/ folder, but exclude all .log files inside it. Which command achieves this?
hard
A. tar -czvf project.tar.gz --exclude='*.log' project/
B. tar -czvf project.tar.gz project/ --exclude='*.log'
C. tar -cvzf project.tar.gz project/ --exclude='*.log'
D. tar -xvzf project.tar.gz --exclude='*.log' project/
Solution
Step 1: Understand exclusion and compression flags
The --exclude='*.log' option excludes files matching the pattern. -c creates, -z compresses with gzip, -v shows progress, and -f specifies the archive filename.
Step 2: Check correct flag order and placement
The exclude option must come before the folder argument. tar -czvf project.tar.gz --exclude='*.log' project/ correctly places --exclude='*.log' before project/ and uses correct flags.
Final Answer:
tar -czvf project.tar.gz --exclude='*.log' project/ -> Option A
Quick Check:
Exclude before folder, use -czvf for compressed archive [OK]
Hint: Put --exclude before folder, use -czvf to create compressed archive [OK]
Common Mistakes:
Placing --exclude after folder argument
Using -x (extract) instead of -c (create)
Mixing flag order or misspelling exclude
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.