Beginner · 5 min · practise every command in the built-in terminal

zip and unzip

zip is cross-platform and widely used for sharing files with Windows users.

Create zip

zip archive.zip file1.txt file2.txt
zip -r archive.zip directory/          # Recursive (for directories)
zip -9 archive.zip files/              # Maximum compression

Extract zip

unzip archive.zip
unzip archive.zip -d /target/directory
unzip -l archive.zip                    # List contents
unzip -o archive.zip                    # Overwrite without asking

Password protected

zip -e secure.zip file.txt             # Add password
unzip secure.zip                        # Will prompt for password

Practice tasks

  1. Create a zip archive of your scripts/ directory
  2. List the contents of a zip archive without extracting it
  3. Extract a zip archive

Commands in this lesson

Archives & Compression