😎
CS1.dev
  • Welcome to Computer Science 1
  • Unit 2
    • Activity 2.1
    • Activity 2.2
    • Activity 2.3
    • Activity 2.4
    • Activity 2.5
    • Activity 2.6
    • Activity 2.7
    • Activity 2.9
    • Activity 2.10
    • Project 2
    • Activity 2.8
    • Activity 2.11
    • Activity 2.12
    • Activity 2.13
    • Activity 2.14
    • Activity 2.15
    • Activity 2.16
    • Activity 2.17
    • Activity 2.18
    • Activity 2.19
    • Project 3
    • Activity 2.20
    • Activity 2.21
    • Activity 2.22
    • Activity 2.23
    • Activity 2.24
    • Project 4
    • Activity 2.25
    • Activity 2.26
    • Activity 2.27
    • Activity 2.28
    • Project 5
    • Activity 2.29
    • Activity 2.30
    • Activity 2.31
    • Activity 2.32
    • Activity 2.33
    • Activity 2.34
    • Activity 2.35
    • Activity 2.36
  • Unit 3
    • Activity 3.1
    • Activity 3.2
    • Activity 3.3
    • Activity 3.4
    • Activity 3.5
    • Activity 3.6
    • Activity 3.7
    • Activity 3.8
    • Activity 3.9
    • Activity 3.10
    • Activity 3.11
    • Project 6
    • Activity 3.12
  • Activity 3.13
  • Activity 3.14
  • Activity 3.15
  • Activity 3.16
  • Project 7
  • Activity 3.17
  • Activity 3.18
  • Activity 3.19
  • Project 8
  • Linux
    • bash
    • cat
    • cd
    • chmod
    • df
    • echo
    • find
    • grep
    • less
    • ls
    • mkdir
    • more
    • pwd
    • tar
    • touch
    • unzip
    • zip
Powered by GitBook
On this page
  1. Linux

unzip

The unzip command in Linux is used to extract files and directories from ZIP archives. It's the counterpart to the zip command and is widely used for decompressing files that have been compressed using the ZIP compression algorithm. Here are the key aspects and functionalities of the unzip command:

  1. Extracting Files: To extract all the contents of a ZIP archive, use unzip followed by the filename. For example, unzip file.zip will extract all files and directories in file.zip to the current directory.

  2. Listing Archive Contents: If you want to see the contents of a ZIP archive without extracting it, you can use unzip -l file.zip. This command lists the files included in file.zip.

  3. Extracting Specific Files: To extract specific files from a ZIP archive, specify the file names after the archive name. For instance, unzip archive.zip file1.txt file2.txt will extract only file1.txt and file2.txt from archive.zip.

  4. Extracting to a Different Directory: If you want to extract files to a different directory rather than the current one, use the -d option. For example, unzip file.zip -d /path/to/directory will extract the contents of file.zip into /path/to/directory.

  5. Overwriting Existing Files: When extracting, if there are existing files with the same names, unzip will prompt for action (overwrite, skip, etc.). You can automate this process using options like -o to overwrite files without prompting or -n to never overwrite existing files.

  6. Preserving File Timestamps and Permissions: unzip typically preserves the original timestamps and permissions of the files in the ZIP archive.

  7. Handling Encrypted Archives: If a ZIP archive is password-protected, unzip will prompt for the password. You can also specify the password with the -P option, but this is not secure as it may be visible in the command history or process list.

  8. Testing Archive Integrity: To check the integrity of a ZIP archive without extracting it, use unzip -t file.zip. This command tests whether the archive is corrupted.

  9. Verbose Output: Using the -v option with unzip provides more verbose output, showing additional details about the extraction process.

PrevioustouchNextzip

Last updated 1 year ago