0
0
Linux CLIscripting~20 mins

zip and unzip in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Zip Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of listing files after zipping?
You have a directory with files: file1.txt, file2.txt, and file3.txt. You run the command zip archive.zip file1.txt file2.txt. Then you run ls archive.zip. What is the output?
Linux CLI
zip archive.zip file1.txt file2.txt
ls archive.zip
ANo such file or directory
Bfile1.txt file2.txt
Carchive.zip file1.txt file2.txt
Darchive.zip
Attempts:
2 left
💡 Hint
The ls command lists files and directories by name.
💻 Command Output
intermediate
2:00remaining
What happens when you unzip a file into a directory?
You have a zip file named docs.zip containing files readme.md and guide.pdf. You run unzip docs.zip -d extracted_docs. What will be the result?
Linux CLI
unzip docs.zip -d extracted_docs
ls extracted_docs
Adocs.zip
Breadme.md guide.pdf
Cextracted_docs
DNo such file or directory
Attempts:
2 left
💡 Hint
The -d option specifies the directory to extract files into.
📝 Syntax
advanced
2:00remaining
Which command correctly creates a zip archive including all files in a directory?
You want to create a zip file named backup.zip that contains all files inside the directory project. Which command is correct?
Azip -r backup.zip project
Bzip backup.zip project/*
Czip backup.zip -r project
Dzip backup.zip project
Attempts:
2 left
💡 Hint
The -r option means recursive, to include directories and their contents.
🔧 Debug
advanced
2:00remaining
Why does this unzip command fail with 'cannot find or open' error?
You run the command unzip myfiles.zip -d /home/user/docs but get the error: cannot find or open myfiles.zip, myfiles.zip.zip or myfiles.zip.ZIP. What is the likely cause?
Linux CLI
unzip myfiles.zip -d /home/user/docs
AThe file myfiles.zip does not exist in the current directory
BThe destination directory /home/user/docs does not exist
CThe unzip command requires sudo privileges
DThe -d option is used incorrectly
Attempts:
2 left
💡 Hint
Check if the zip file is in the current folder where you run the command.
🚀 Application
expert
3:00remaining
How to create a zip archive excluding certain file types?
You want to zip all files in the current directory but exclude all .log files. Which command achieves this?
Azip -r archive.zip . --ignore='*.log'
Bzip archive.zip * --exclude='*.log'
Czip -r archive.zip . -x '*.log'
Dzip archive.zip . -exclude '*.log'
Attempts:
2 left
💡 Hint
The -x option excludes files matching a pattern.