Search Docs by Keyword

Table of Contents

Extracting compressed .zip or .7z archives with 7-Zip

p7zip/7-Zip is installed on the clusters, making it easy to create compressed/zipped archives or unzip/extract compressed archives.

Use 7-Zip using the command line. If you are using the Open OnDemand interface, you can start a Terminal Emulator window in the Remote Desktop application to extract the contents of a .zip or .7z archive file.

Some examples are included below:

Extracting archives

To list the contents of the file readme_docs.7z:
7z l readme_docs.7z

To extract an archive called readme_docs.7z to a new folder in your current directory called “extracted”, you would type
7z x readme_docs.7z -o./extracted

  • x is for “eXtract” (this command is useful if you are uncompressing a data source with its own directories – it preserves the directory structure. If you just want to extract everything in the archive without preserving directory structure within it, you can use the e command instead of x)
  • -o sets the Output directory
  • . means your current directory
  • note there is no space between the -o and the path for your extracted content.

To simply extract to the current folder :
7z x readme_docs.7z

Creating and adding to archives

To create an archive file, use the a command to Add files to an archive.
Specify the name of the archive, then the files that should be added to the archive.

This command adds the files doc1.txt and doc2.docx to an archive readme_docs.7z using the 7z compression format (default)
7z a readme_docs.7z doc1.txt doc2.docx

This command adds the contents of the directory “docs” to an archive readme_docs.7z using the 7z compression format (default)
7z a readme_docs.7z docs/

This command adds all files ending in “.txt” in the current directory to an archive readme_docs.7z using the 7z compression format (default)
7z a readme_docs.7z *.txt

This command adds the files doc1.txt and doc2.docx to an archive readme_docs.tar using the TAR format.
Other options include -t7z (default), -tgzip, -tzip, -tbzip2, -tudf.
7z a -ttar readme_docs.tar doc1.txt doc2.docx

More information

In Terminal, you can type 7z for a list of commands and switches, or man 7z for detailed descriptions and examples.

© The President and Fellows of Harvard College
Except where otherwise noted, this content is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International license.