1. MagicESP
  2. Ubuntu Server 22.04
  3. Compress and Decompress Linux Command

Compress and Decompress Linux Command

I can never remember compress and decompress Linux command, namely, tar. The good thing is, I don't use it everyday.

Linux Command to Decompress or Unpacking

Type your file name, I will show you the right command to decompress.

.tar.gz / .tgz

tar zxvf {{ filename.value }}

.tar.bz2

tar jxvf {{ filename.value }}

.zip

unzip {{ filename.value }}

.gz

gunzip {{ filename.value }}
gzip -d {{ filename.value }}

.bz2

bunzip2 {{ filename.value }}
bzip2 -d {{ filename.value }}

.tar

tar xvf {{ filename.value }}

Linux Command to Compress or Packaging

.tar.gz / .tgz

tar zcvf {{ path_basename }}.tar.gz {{ path.value }}

.tar.bz2

tar jcvf {{ path_basename }}.tar.bz2 {{ path.value }}

.zip

zip {{ path_basename }}.zip {{ path.value }}

.tar

tar cvf {{ path_basename }}.tar {{ path.value }}

Single File Compress

.gz

gzip {{ file.value }}

.bz2

bzip2 -z {{ file.value }}