Bash Commands: tar
tar options1:
- c -> create archive
- x -> extract archive
- v -> verbose (optional; list files being processed)
- t -> list (i.e. do not extract) archive contents
- f -> the archive's filename
- z -> filter through gzip (.tgz; .tar.gz)
- j -> filter through bzip2 (.bz2; .tbz; .tar.bz2)
Uncompressed Archives (.tar)1
To create an uncompressed archive:
tar cvf archiveName.tar folderToBeArchived
To extract an uncompressed archive:
tar xvf archiveName.tar
To list/view archive contents without extracting:
tar tvf archiveName.tar
To create and compress a gzip archive:
tar cvfz archiveName.tar.gz folderToBeArchived
To extract a gzip archive:
tar xvfz archiveName.tar.gz
To list/view gzip archive contents without extracting:
tar tvfz archiveName.tar.gz
To create and compress a bzip2 archive :
tar cvfj archiveName.tar.bz2 folderToBeArchived
To extract a bzip2 archive:
tar xvfj archiveName.tar.bz2
To list/view bzip2 archive contents without extracting:
tar tvfj archiveName.tar.bz2
To create an archive of a directory with xz compression:
tar cfJv archiveName.tar.xz folderToBeArchived
To extract an archive:
tar xfJv archiveName.tar.xz
xz File Compression Utility (.xz)2
To compress a file or directory with xz compression:
xz archiveName.xz destinationFolder # DOES NOT ACTUALLY WORK :(
tar -c --xz -f my_archive.tar.xz /some_directory # results in my_archive.tar.xz
To extract a file or directory with the .xz extension:
xz -d archiveName.xz destinationFolder