Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

There is a yes command in unix/linux which basically infinitely prints y to the stdout. What is the point of it, and how is it useful?

share|improve this question
For example yes | rm filename. –  manatwork Sep 6 '12 at 13:05
Sometimes you get a lot of errors from pdflatex that are not fatal and you cannot be bothered to fix, then repeatedly sending newlines with yes '' | pdflatex report.tex works very effectively. –  danr Sep 6 '12 at 13:26
Also useful when need to paste some constant text as in codegolf.stackexchange.com/a/6590/4198 –  manatwork Sep 6 '12 at 14:21
@manatwork: Why not rm -f filename? –  Maciej Piechotka Sep 6 '12 at 16:34
yes | "Does anyone know what might this be useful for?" –  SpellingD Sep 6 '12 at 16:35

2 Answers 2

up vote 23 down vote accepted

yes can be used to send an affirmative (or negative; e.g. yes n) response to any command that would otherwise request one, thereby causing the command to run non-interactively.

The yes command in conjunction with the head command can be used to generate large volume files for means of testing.

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

In 2006, the yes command received publicity for being a means to test whether or not a user's MacBook is affected by the Intermittent Shutdown Syndrome. By running the yes command twice via Terminal under Mac OS X, users were able to max out their computer's CPU, and thus see if the failure was heat related

via wikipedia: http://en.wikipedia.org/wiki/Yes_(Unix)

share|improve this answer
For extra damage, try yes `yes yes` –  sendmoreinfo Apr 21 '13 at 13:49
@sendmoreinfo Evil –  Tobias Kienzler Nov 13 '13 at 9:12

A coworker used this in a novel way to input a password

yes password | passwd
share|improve this answer
passwd will ask for the old password first, if the user is not root or a superuser and will not continue unless the correct password is entered. So either the user is root or password is the old password as well and nothing is changed. –  Michael Konietzka Nov 10 '13 at 16:25
@MichaelKonietzka indeed. But with the conditions you mentioned it's a useful use case still. –  frogstarr78 Nov 16 '13 at 6:00
Except this would persist in history in plaintext. Crazeyyy. –  Gleno Aug 16 '14 at 19:20
@Gleno in bash, you can precede it with a space to prevent it from being recorded (as in stackoverflow.com/q/640403/118153) –  Iiridayn Dec 8 '14 at 8:36

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.