当前位置:   article > 正文

Ubuntu 或 Centos 解决方法 tar (child): xz: Cannot exec: No such file or directory 安装/源码安装

tar (child): xz: cannot exec: no such file or directory

Xz 软件包包含文件压缩和解压缩工具,它能够处理 lzma 和新的 xz 压缩文件格式。使用 xz 压缩文本文件,可以得到比传统的 gzip 或 bzip2 更好的压缩比。

在使用 linux 下 tar 命令时,可能会出现以下问题

tar (child): xz: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
  • 1
  • 2
  • 3

这种情况实际上是由于缺少 xz导致 tar执行出错
可以用包管理器安装 xz 解决

ubuntu

sudo apt install -y xz-utils
  • 1

centos

sudo yum install -y xz
  • 1

源码安装

下载解压源码

下载

wget https://tukaani.org/xz/xz-5.2.6.tar.gz
  • 1

解压

tar xvf xz-5.2.6.tar.gz
  • 1
进入文件夹并开始编译

进入文件夹

cd xz-5.2.6
  • 1

安装 GCC Make
Ubuntu

sudo apt install gcc make
  • 1

Centos

sudo yum install gcc make
  • 1

执行配置,生成 Makefile

./configure
  • 1

应出现类似如下的提示:

config.status: creating po/Makefile.in
config.status: creating lib/Makefile
config.status: creating src/Makefile
config.status: creating src/liblzma/Makefile
config.status: creating src/liblzma/api/Makefile
config.status: creating src/xz/Makefile
config.status: creating src/xzdec/Makefile
config.status: creating src/lzmainfo/Makefile
config.status: creating src/scripts/Makefile
config.status: creating tests/Makefile
config.status: creating debug/Makefile
config.status: creating src/scripts/xzdiff
config.status: creating src/scripts/xzgrep
config.status: creating src/scripts/xzmore
config.status: creating src/scripts/xzless
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing po-directories commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

执行 make 进行编译

make
  • 1

应看到类似如下提示:

make[3]: Entering directory '/root/xz-5.2.6/src'
make[3]: Nothing to be done for 'all-am'.
make[3]: Leaving directory '/root/xz-5.2.6/src'
make[2]: Leaving directory '/root/xz-5.2.6/src'
Making all in po
make[2]: Entering directory '/root/xz-5.2.6/po'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/root/xz-5.2.6/po'
Making all in tests
make[2]: Entering directory '/root/xz-5.2.6/tests'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/root/xz-5.2.6/tests'
make[2]: Entering directory '/root/xz-5.2.6'
make[2]: Leaving directory '/root/xz-5.2.6'
make[1]: Leaving directory '/root/xz-5.2.6'
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15

安装

sudo make install
  • 1

看到类似以下提示证明成功

make[2]: Entering directory '/root/xz-5.2.6'
make[2]: Nothing to be done for 'install-exec-am'.
 /usr/bin/mkdir -p '/usr/local/share/doc/xz'
 /usr/bin/install -c -m 644 AUTHORS COPYING COPYING.GPLv2 NEWS README THANKS TODO doc/faq.txt doc/history.txt doc/xz-file-format.txt doc/lzma-file-format.txt '/usr/local/share/doc/xz'
 /usr/bin/mkdir -p '/usr/local/share/doc/xz/examples'
 /usr/bin/install -c -m 644 doc/examples/00_README.txt doc/examples/01_compress_easy.c doc/examples/02_decompress.c doc/examples/03_compress_custom.c doc/examples/04_compress_easy_mt.c doc/examples/Makefile '/usr/local/share/doc/xz/examples'
 /usr/bin/mkdir -p '/usr/local/share/doc/xz/examples_old'
 /usr/bin/install -c -m 644 doc/examples_old/xz_pipe_comp.c doc/examples_old/xz_pipe_decomp.c '/usr/local/share/doc/xz/examples_old'
make[2]: Leaving directory '/root/xz-5.2.6'
make[1]: Leaving directory '/root/xz-5.2.6'
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

验证查看 XZ 版本

xz -V
  • 1

看到以下提示证明安装成功

xz (XZ Utils) 5.2.6
liblzma 5.2.4
  • 1
  • 2
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/195786
推荐阅读
相关标签
  

闽ICP备14008679号