Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I see some linux page says how to install the key:

  wget -O - | sudo apt-key add -

What is "-O -" in wget?

It seems related with "add -".

How these works?

Thank you~

share|improve this question
- in wget is stdout (standard output), - in apt is stdin (standard input) – nickanor Jan 10 '13 at 7:46
up vote 3 down vote accepted

The option -O - prints the downloaded file to standard output (instead of a ordinary file) and the - option in apt-key reads from standard input. The command is equivalent to the two commands:

sudo apt-key add ros.key

When you chain both commands you don't have to bother with saving a file and usually the command is shorter.

share|improve this answer

I used ** to indicate it is important. from man wget

-O file
       The documents will not be written to the appropriate files, but all
       will be concatenated together and written to file.  ** If - is used as
       file, documents will be printed to standard output, disabling link
       conversion.  (Use ./- to print to a file literally named -.) **

       Use of -O is not intended to mean simply "use the name file instead
       of the one in the URL;" rather, it is analogous to shell
       redirection: wget -O file http://foo is intended to work like wget
       -O - http://foo > file; file will be truncated immediately, and all
       downloaded content will be written there.

and from man apt-key

add filename
       Add a new key to the list of trusted keys. The key is read from
       filename, or ** standard input if filename is -.**

this explains your command.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.