node.js - 在 Linux 上从二进制文件安装 Node 需要哪些 tar 选项?

标签 node.js linux tar

背景

我下载了适用于 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/

相关文章:

node.js - npm 脱网失败

node.js - Mongoose 查询以增加项目数组中的字段(如果存在),否则将其添加到文档中(很难表述此标题)

node.js - 如何更改 Angular 快速入门中的默认精简服务器端口?

linux - 如何在嵌入式Linux中有效地在VFAT分区上创建大文件

c - Linux下可以设置本地时间的定时器吗?

linux - Unix 系统命令退出代码

python - 与Python `arcname`模块中的 `tarfile`选项相对应的tar选项是什么?

linux - 如何使用 tar 备份 docroot

node.js - 为什么我的 .tar 文件会生成数百个 PaxHeader 文件?

node.js - npm 错误!代码 烯醇本地