背景
我下载了适用于 64 位 linux 的二进制文件,我正在学习几个教程,每个教程都有相似的选项:
tar -C /usr/local --strip-components 1 -xzf /path/to/node.tar.gz
我总是得到这个错误:
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
我用谷歌搜索了一下,似乎我已经通过其中一个开关手动指定了 gzip 文件格式。文件实际上是 tar.xz
,而不是 tar.gz
。在旧版本中它可能是 tar.gz
。
我想知道所有这些选项是什么意思,我需要哪个? 是否有自动检测格式选项?
这是运行 info tar
时说的:
-C, --directory DIR
change to directory DIR
--strip-components=NUMBER
strip NUMBER leading components from file names on extraction
-x, --extract, --get
extract files from an archive
-z, --gzip, --gunzip --ungzip
-f, --file ARCHIVE
use archive file or device ARCHIVE
问题
我不明白选项 -f
、--strip-components
。
-f
- 除了文件还能是什么?什么是“设备存档”?
--strip-components
- --strip-components 1
在这里到底做了什么?
我没有在文件中看到任何数字。
请提供会受 --strip-components
影响的文件名示例,并说明影响方式。
在 linux 上安装 nodejs 的想法是什么?
解压到/usr/local
还是需要做什么?
最佳答案
首先,tar
足够“智能”以检测存档中使用的压缩方法,因此无需指定 -z 或 -j。
-f - What else can it be but a file? What is "device archive"?
设备存档可以是/dev/your_tar 中附加到您机器的磁带存档
--strip-components - What does --strip-components 1 exactly do
tar xfz /var/www/site/site.gz --strip-components=2
将创建/var/site。
关于node.js - 在 Linux 上从二进制文件安装 Node 需要哪些 tar 选项?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44027314/