组合命令“ curl”和“ apt-key add”的含义是什么?


19

安装Heroku CLI时遇到一个命令。这是命令:

curl -L https://cli-assets.heroku.com/apt/release.key | sudo apt-key add -

它是什么意思,如何运作?

Answers:


34

curl是从链接下载内容的实用程序。默认情况下,它写入STDOUT(即从终端中的链接打印内容)

-L选项curl表示:

-L, --location
         (HTTP/HTTPS)  If the server reports that the requested page has moved to a 
         different location (indicated with a Location: header and a 3XX response 
         code), this option will make curl redo the request on the new place...

操作员|是一个管道,它将命令前的输出作为命令后的STDIN传递。

apt-key是一个实用程序,用于添加可信密钥以适合存储库。您可以看到如何add处理man apt-key

add <filename>
         Add a new key to the list of trusted keys. The key is read from the 
         filename given with the parameter filename or if the filename is -
         from standard input.

如前所述,它-告诉您apt key add应该从STDIN中读取密钥文件,在这种情况下,这是从curl命令中传递的内容,因此:

即使此链接已移动,也请下载该链接上的所有内容,并将其添加为受信任的APT存储库密钥。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.