While installing Heroku CLI there's a command I encountered. Here is the command:

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

What does it mean and how does it work?

1 Answer 1


curl is a utility to download something from a link. By default, it writes to STDOUT (ie prints stuff from the link in the terminal)

The -L option to curl means:

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

The operator | is a pipe, which passes the output of the command before it as the STDIN of the command after it.

apt-key is a utility to add trusted keys to apt for repositories. You can see what add does with 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.

As it mentions, - tells apt key add that the key file should be read from STDIN, which in this case is what was piped from the curl command, so, in sum:

Download whatever is at this link, even if it has moved, and add it as a trusted APT repository key.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .