0
0
Linux CLIscripting~20 mins

tar (create and extract archives) in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Tar Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the output of this tar command?
You run the command tar -cf archive.tar file1.txt file2.txt in a directory containing file1.txt and file2.txt. What does the command do?
Linux CLI
tar -cf archive.tar file1.txt file2.txt
ACreates a compressed archive named archive.tar.gz containing file1.txt and file2.txt
BCreates an uncompressed archive named archive.tar containing file1.txt and file2.txt
CExtracts files from archive.tar into the current directory
DLists the contents of archive.tar without extracting
Attempts:
2 left
💡 Hint
The -c option means create, and -f specifies the archive file name.
💻 Command Output
intermediate
1:30remaining
What does this command output?
You run tar -tf archive.tar. What is the output?
Linux CLI
tar -tf archive.tar
ALists the names of files inside archive.tar
BExtracts all files from archive.tar
CCreates a new archive named archive.tar
DDeletes archive.tar
Attempts:
2 left
💡 Hint
The -t option lists contents without extracting.
🔧 Debug
advanced
2:00remaining
Why does this tar extraction command fail?
You run tar -xf archive.tar.gz but get an error saying 'Cannot open: Not in gzip format'. What is the problem?
Linux CLI
tar -xf archive.tar.gz
AThe archive is not compressed with gzip, so -z option is missing
BThe archive file does not exist
CThe archive is corrupted
DThe -x option is invalid for extraction
Attempts:
2 left
💡 Hint
Check if the archive is compressed and if the correct option is used.
🚀 Application
advanced
2:00remaining
How to create a compressed archive with tar?
You want to create a gzip compressed archive named backup.tar.gz containing the directory project. Which command achieves this?
Atar -cf backup.tar.gz project
Btar -tf backup.tar.gz project
Ctar -xf backup.tar.gz project
Dtar -czf backup.tar.gz project
Attempts:
2 left
💡 Hint
Use the option that compresses with gzip while creating.
🧠 Conceptual
expert
2:30remaining
What is the effect of this tar command?
What does the command tar --exclude='*.log' -czf archive.tar.gz /var/logs do?
AExtracts files from archive.tar.gz excluding .log files
BCreates a gzip compressed archive of /var/logs including all files
CCreates a gzip compressed archive of /var/logs excluding files ending with .log
DLists files in /var/logs excluding .log files
Attempts:
2 left
💡 Hint
The --exclude option skips files matching the pattern during archive creation.