How to decompress .tar files in Linux
1. Packing and compression
tar -cvf etc.tar /app/etc #打包 tar -zcvf pack.tar.gz pack/ #打包压缩为一个.gz格式的压缩包 tar -jcvf pack.tar.bz2 pack/ #打包压缩为一个.bz2格式的压缩包 tar -Jcvf pack.tar.xz pack/ #打包压缩为一个.xz格式的压缩包
2. Unpack and decompress
tar -xvf pack.tar # 解包pack.tar文件 tar -zxvf pack.tar.gz /pack #解包解压.gz格式的压缩包到pack文件夹 tar -jxvf pack.tar.bz2 /pack #解包解压.bz2格式的压缩包到pack文件夹 tar -Jxvf pack.tar.xz /pack #解包解压.xz格式的压缩包到pack文件夹
Key explanation: The tar tool itself does not have the compression function, and it needs to be combined with a compression tool to achieve better compression.
-j: bzip2
-z: gzip
-J: xz
-c: Packaging
-x: Unpacking
Recommended learning: Linux video tutorial
The above is the detailed content of How to decompress .tar files in linux. For more information, please follow other related articles on the PHP Chinese website!