This article covers how to Tar Untar and Zip Files.
These commands can be run from within SSH to tar or untar a tarball file. These files are typically used in packaged backups or a directory that has been compressed.
These commands will compress the selected directory into a tarball file, which will be located within the original directory.
[code description="To compress a directory into a tar file (.tar):"]tar -xvf FILENAME.tar DIRECTORY/[/code]
[code description="To compress a directory into a gzip tar file (.tgz or .tar.gz):"]tar -czvf FILE.tar.gz DIRECTORY/[/code]
[code description="To compress a directory into a bzip2 tar file (.tbz or .tar.bz2):"]tar -jxvf FILE.tar.bz2 DIRECTORY/[/code]
These commands will extract the tarball file into the current directory it is located in.
[code description="To uncompress a tar file (.tar):"]tar xvf FILE.tar[/code]
[code description="To uncompress a gzip tar file (.tgz or .tar.gz):"]tar xvzf FILE.tar.gz[/code]
[code description="To uncompress a bzip2 tar file (.tbz or .tar.bz2):"]tar xvjf FILE.tar.bz2[/code]
[code description="To compress the selected directory into a zip file, which will be located within the original directory:"]zip -r fFILE.zip DIRECTORY/[/code]
[code description="To extract the selected zip file, which will be uncompressed into the directory the zip is located in:"]unzip FILE.zip[/code]
If you wish to extract the tarball file to a specific directory, adding the following to the end of the command will extract it to the specified location:
[code description=""]-C /DIRECTORY/[/code]
These commands can be run from within SSH to tar or untar a tarball file. These files are typically used in packaged backups or a directory that has been compressed.
Tar
These commands will compress the selected directory into a tarball file, which will be located within the original directory.
[code description="To compress a directory into a tar file (.tar):"]tar -xvf FILENAME.tar DIRECTORY/[/code]
[code description="To compress a directory into a gzip tar file (.tgz or .tar.gz):"]tar -czvf FILE.tar.gz DIRECTORY/[/code]
[code description="To compress a directory into a bzip2 tar file (.tbz or .tar.bz2):"]tar -jxvf FILE.tar.bz2 DIRECTORY/[/code]
Untar
These commands will extract the tarball file into the current directory it is located in.
[code description="To uncompress a tar file (.tar):"]tar xvf FILE.tar[/code]
[code description="To uncompress a gzip tar file (.tgz or .tar.gz):"]tar xvzf FILE.tar.gz[/code]
[code description="To uncompress a bzip2 tar file (.tbz or .tar.bz2):"]tar xvjf FILE.tar.bz2[/code]
Zip and Unzip
[code description="To compress the selected directory into a zip file, which will be located within the original directory:"]zip -r fFILE.zip DIRECTORY/[/code]
[code description="To extract the selected zip file, which will be uncompressed into the directory the zip is located in:"]unzip FILE.zip[/code]
Additional Notes
If you wish to extract the tarball file to a specific directory, adding the following to the end of the command will extract it to the specified location:
[code description=""]-C /DIRECTORY/[/code]