Ubuntu – the “yes” command

command line

I issued a command in the Ubuntu terminal that required me to type yes but I discovered that it only asks me the first time, but I had already pressed enter before I realized. So I expected a "command not found" message but instead I got a never-ending stream of "y"s. This seems to be the only thing this does, so I'm wondering what the point of this command is and why it outputs "y"s? (Ubuntu 11.10)

Best Answer

From wikipedia:

By itself, the yes command outputs 'y' or whatever is specified as an argument, followed by a newline repeatedly until stopped by the user or otherwise killed; when piped into a command, it will continue until the pipe breaks (i.e., the program completes its execution).

It can also be used to test how well a system handles high loads, as using yes results in 100% processor usage, for systems with a single processor (for a multiprocessor system, a process must be run for each processor). This, for example, can be useful for investigating whether a system's cooling system will be effective when the processor is running at 100%.

Related Question