Qual è il significato dei comandi combinati `curl` +` apt-key add`?


19

Durante l'installazione della CLI di Heroku c'è un comando che ho incontrato. Ecco il comando:

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

Cosa significa e come funziona?

Risposte:


34

curlè un'utilità per scaricare qualcosa da un collegamento. Per impostazione predefinita, scrive su STDOUT (ovvero stampa elementi dal collegamento nel terminale)

L' -Lopzione curlsignifica:

-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...

L'operatore |è una pipe, che passa l'output del comando prima come STDIN del comando dopo di esso.

apt-keyè un'utilità per aggiungere chiavi affidabili per apt per i repository. Puoi vedere cosa addsuccede con 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.

Come menziona, -dice apt key addche il file chiave dovrebbe essere letto da STDIN, che in questo caso è ciò che è stato reindirizzato dal curlcomando, quindi, in sintesi:

Scarica qualunque cosa si trovi a questo link, anche se è stata spostata, e aggiungila come chiave di repository APT attendibile.

Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.