The zip command compresses one or more files into a single archive file with a .zip extension. It helps save space and makes it easier to share multiple files together.
Click to reveal answer
beginner
How do you extract files from a .zip archive using the command line?
Use the unzip command followed by the archive name. For example, unzip archive.zip extracts all files from archive.zip into the current folder.
Click to reveal answer
intermediate
What option do you use with zip to include all files in a folder recursively?
Use the -r option with zip. For example, zip -r archive.zip foldername compresses the folder and all its contents, including subfolders.
Click to reveal answer
beginner
How can you list the contents of a .zip file without extracting it?
Use unzip -l archive.zip. This shows the list of files inside the archive without extracting them.
Click to reveal answer
intermediate
What happens if you try to unzip a file into a folder where files with the same names already exist?
The unzip command will ask if you want to overwrite each existing file. You can press y to overwrite or n to skip. Use the -o option to overwrite all without asking.
Click to reveal answer
Which command compresses files into a .zip archive?
Atar
Bunzip
Czip
Dgzip
✗ Incorrect
The zip command creates .zip archives. unzip extracts them.
How do you extract all files from archive.zip?
Azip archive.zip
Bunzip archive.zip
Ctar -x archive.zip
Dgzip -d archive.zip
✗ Incorrect
Use unzip archive.zip to extract files from a .zip archive.
What option with zip includes all files in folders and subfolders?
A-r
B-l
C-x
D-o
✗ Incorrect
The -r option means recursive, including all subfolders.
Which command lists files inside a zip archive without extracting?
Aunzip -l archive.zip
Bzip -l archive.zip
Ctar -t archive.zip
Dgzip -l archive.zip
✗ Incorrect
unzip -l lists contents of a zip archive.
How to overwrite files automatically when unzipping?
Aunzip -r
Bunzip -f
Czip -o
Dunzip -o
✗ Incorrect
The -o option overwrites existing files without asking.
Explain how to create a zip archive of a folder including all its files and subfolders.
Think about compressing a whole folder recursively.
You got /4 concepts.
Describe how to safely extract files from a zip archive and check what files are inside before extracting.
Listing contents first helps avoid surprises.
You got /4 concepts.
Practice
(1/5)
1. What does the zip command do in Linux?
easy
A. It extracts files from a compressed archive.
B. It compresses one or more files into a single archive file.
C. It lists the contents of a directory.
D. It deletes files permanently.
Solution
Step 1: Understand the purpose of zip
The zip command is used to compress files into one archive to save space or organize files.
Step 2: Differentiate from other commands
unzip extracts files, ls lists files, and rm deletes files, so these are not correct.
Final Answer:
It compresses one or more files into a single archive file. -> Option B
Quick Check:
zip = compress files [OK]
Hint: Zip means pack files together into one compressed file [OK]
Common Mistakes:
Confusing zip with unzip command
Thinking zip lists files
Assuming zip deletes files
2. Which of the following is the correct syntax to create a zip archive named archive.zip including all files in the folder docs recursively?
easy
A. zip -r archive.zip docs
B. zip -x archive.zip docs
C. unzip -r archive.zip docs
D. zip archive.zip docs
Solution
Step 1: Identify the option for recursive zip
The -r option tells zip to include folders and their contents recursively.
Step 2: Check command correctness
zip -r archive.zip docs correctly creates the archive including all files inside docs. Other options are incorrect or for unzip.
Final Answer:
zip -r archive.zip docs -> Option A
Quick Check:
Use -r to zip folders recursively [OK]
Hint: Use -r option with zip to include folders recursively [OK]
Common Mistakes:
Using unzip instead of zip to create archive
Forgetting -r to include folders
Using -x which excludes files
3. What will be the output of the command unzip -l archive.zip?
medium
A. It lists the contents of archive.zip without extracting.
B. It deletes archive.zip after listing contents.
C. It extracts all files from archive.zip to current directory.
D. It compresses files into archive.zip.
Solution
Step 1: Understand the -l option in unzip
The -l option lists the files inside the zip archive without extracting them.
Step 2: Differentiate from other actions
Extracting files uses unzip without -l, deleting is not done by unzip, and compressing is done by zip, not unzip.
Final Answer:
It lists the contents of archive.zip without extracting. -> Option A
Quick Check:
unzip -l lists archive contents [OK]
Hint: Use unzip -l to peek inside zip without extracting [OK]
Common Mistakes:
Thinking unzip -l extracts files
Confusing zip and unzip commands
Assuming unzip deletes files
4. You run unzip archive.zip but get an error saying "cannot find or open archive.zip". What is the most likely cause?
medium
A. The zip archive is corrupted and cannot be opened.
B. You used the wrong command; unzip cannot extract files.
C. The archive.zip file does not exist in the current directory.
D. You need to use the -r option with unzip to extract.
Solution
Step 1: Analyze the error message
"cannot find or open archive.zip" means the file is missing or path is wrong.
Step 2: Check command and options
unzip is correct to extract files; no -r option is needed. Corruption would give a different error.
Final Answer:
The archive.zip file does not exist in the current directory. -> Option C
Quick Check:
File missing causes cannot find error [OK]
Hint: Check file exists in current folder before unzip [OK]
Common Mistakes:
Assuming unzip command is wrong
Using -r option with unzip incorrectly
Ignoring file location or name typos
5. You want to create a zip archive named backup.zip that includes all files and folders inside project, but exclude all .log files. Which command will do this correctly?
hard
A. zip backup.zip project/*.log
B. unzip -r backup.zip project -x '*.log'
C. zip -r backup.zip project --exclude '*.log'
D. zip -r backup.zip project -x '*.log'
Solution
Step 1: Use recursive zip with exclusion
The -r option includes folders recursively, and -x '*.log' excludes all .log files.
Step 2: Validate command correctness
zip -r backup.zip project -x '*.log' uses correct syntax. zip backup.zip project/*.log only zips .log files, C uses invalid --exclude, and D uses unzip which cannot create archives.
Final Answer:
zip -r backup.zip project -x '*.log' -> Option D
Quick Check:
Use -r to recurse and -x to exclude files [OK]
Hint: Use -x '*.ext' to exclude files when zipping recursively [OK]
Common Mistakes:
Using unzip instead of zip to create archive
Wrong exclude syntax like --exclude
Not using -r to include folders
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.