Compressed Files

Chester Wyke July 28, 2023 Updated: April 15, 2025 #debian

Compressing files

Using target file extension

Only tested and confirmed to work with:

tar -caf archive.tar.xz file1 file2 file3

Can be used with * to include all files in folder

tar -caf archive.tar.xz *

Specify compression

Compression options

 -a, --auto-compress        use archive suffix to determine the compression program
-j, --bzip2                filter the archive through bzip2
-J, --xz                   filter the archive through xz
    --lzip                 filter the archive through lzip
    --lzma                 filter the archive through xz
    --lzop                 filter the archive through lzop
    --zstd                 filter the archive through zstd
-z, --gzip, --gunzip, --ungzip   filter the archive through gzip

Example

tar -cf archive.tar.xz file1 file2 file3 --xz

Extracting files

TAR

tar -xf archive.tar.xz

Tar relevant switches

Taken from help message

Zip

unzip archive.zip

Uncompress .Z files

Source: https://www.linuxfordevices.com/tutorials/linux/uncompress-z-file

uncompress archive.z

or

gzip -d archive.z