Katina T.


The yes command will change your life

Katina T.'s photo
Katina T.
·Oct 31, 2021·

2 min read

How to use the yes command in Linux

  1. Open the terminal in your favorite distribution
  2. Type yes

The command will continuously output "y" until you kill it (which you can do by pressing CTRL + C)


Using yes to save time

When installing applications or updates, instead of manually entering "y" or "yes" every single time a prompt appears, you can pipe the output of the yes command into another.

For example you can run the following:

yes | sudo apt-get upgrade

All prompts that ask "Do you want to to do this? [Y\n]" will be answered automatically.

in my personal experience, I have started application installations and have gotten out of my seat for a few hours only to come back to see that the installation isn't finished because I had to physically press "y" on my keyboard to answer a prompt.

I really wish someone had shown me the yes command towards the beginning of my Linux journey so I could have avoided that pain.

Using yes for light motivation

Yes is not limited to just outputting "y". It can output any string you want if you pass the string as an argument.

yes [your string here]

For example, running the following will output "you can do it!" indefinitely until you kill the process.

yes you can do it!


Additional readings

Share this