Archives

Create and extract archives

The most common types of archives on Linux are tar and ZIP. There are different commands for working with each one.

tar

To work with .tar archives use the tar command. To archive the animals directory, use tar -cf animals.tar animals/. To extract the archive, use tar -xf animals.tar.

tar extracts to the current directory by default. If you want to extract to a different directory, use the -C flag:

        $ tar -xf animals.tar -C myamazingfolder/
        
      

Extracts animals.tar to myamazingfolder

ZIP

For ZIP archives, there are two different commands to know: zip and unzip. Create an archive with zip -r animals.zip animals/ and extract using unzip animals.zip. For the unzip command, use -d to extract to another directory:

        $ unzip animals.zip -d myamazingfolder/