Linux
Command
Library
Basics
Tips
Commands
Compression & Archiving
Create a tar archive
$
tar
cf [archive].tar [files]
$
tar
czf [archive].tar.gz [files]
$
tar
cjf [archive].tar.bz2 [files]
$
tar
cJf [archive].tar.xz [files]
Extract a tar archive
$
tar
xf [archive].tar
$
tar
xzf [archive].tar.gz
$
tar
xjf [archive].tar.bz2
$
tar
xJf [archive].tar.xz
Extract to a specific directory
$
tar
xf [archive].tar -C [directory]
List archive contents
$
tar
tf [archive].tar
$
tar
tzf [archive].tar.gz
Compress with gzip
$
gzip
[file]
$
gzip
-k [file]
$
gzip
-9 [file]
Decompress gzip
$
gunzip
[file].gz
$
zcat
[file].gz
Compress with bzip2
$
bzip2
[file]
$
bzip2
-k [file]
Decompress bzip2
$
bunzip2
[file].bz2
$
bzcat
[file].bz2
Compress with xz
$
xz
[file]
$
xz
-k [file]
$
xz
-9 [file]
Decompress xz
$
unxz
[file].xz
$
xzcat
[file].xz
Compress with zstd
$
zstd
[file]
$
zstd
-k [file]
$
zstd
-19 [file]
Decompress zstd
$
unzstd
[file].zst
$
zstdcat
[file].zst
Create a zip archive
$
zip
[archive].zip [files]
$
zip
-r [archive].zip [directory]
$
zip
-e [archive].zip [files]
Extract a zip archive
$
unzip
[archive].zip
$
unzip
[archive].zip -d [directory]
$
unzip
-l [archive].zip
Show zip archive info
$
zipinfo
[archive].zip
Create a 7z archive
$
7z
a [archive].7z [files]
Extract a 7z archive
$
7z
x [archive].7z
List 7z archive contents
$
7z
l [archive].7z
Create a cpio archive
$
find
. |
cpio
-o > [archive].cpio
Extract a cpio archive
$
cpio
-id < [archive].cpio
Extract a rar archive
$
unrar
x [archive].rar
Create an ar archive
$
ar
rcs [archive].a [files]
> TERMINAL_GEAR
Curated for the Linux community
Copied to clipboard