• Home
  • Store
  • Blog
  • Contact
  • Home
  • Store
  • Blog
  • Contact
  • #linux
  • |
  • #commandline
  • |
  • #softwareengineering
  • |
  • #embeddedsystems
  • |
  • #compilers
  • ...
  • View All >>

Intro To 'yes' Command In Linux

2023-05-08 - By Robert Elder

     I use the 'yes' command like this:

yes

     which prints the letter 'y' as fast as possible:

y
y
y
y
y
...

     You can exit the 'yes' command by pressing the control and 'c' key together.

     The purpose of this command is to spam the letter 'y' as fast as possible as a way of answering 'yes' to applications that ask for confirmation.  For example, this is a file that doesn't have the write permission set for the user:

     

ls -l main.c
4 -r--rw-r-- 1 robert robert 46 May  8 10:31 main.c

     If I try to delete it, I'll get a confirmation prompt asking for input.

rm main.c
rm: remove write-protected regular file 'main.c'?

     If I run the 'yes' command and pipe its output into the 'rm' command, the file will be deleted without asking first:

yes | rm main.c
ls -l
total 0

     This behavior is particularly useful for writing automated scripts that need to run without human intervention:

#!/bin/bash

#  Deletes file automatically without prompt
yes | rm main.c

     In the case of using a pipe with the 'yes' command, the 'yes' command knows to exit automatically once it receives the SIGPIPE signal.  You can read more information about this concept in the following 'man' page:

man 7 signal

     Another application of the 'yes' command is to trigger high CPU load for testing purposes:

     And that's why the 'yes' command is my favourite Linux command.

Intro To 'stty' Command In Linux
Published 2023-10-04
$1.00 CAD
Terminal Block Mining Simulation Game
Intro To 'nproc' Command In Linux
Published 2023-07-15
Intro To 'comm' Command In Linux
Published 2023-09-06
How To Force The 'true' Command To Return 'false'
Published 2023-07-09
A Surprisingly Common Mistake Involving Wildcards & The Find Command
Published 2020-01-21
A Guide to Recording 660FPS Video On A $6 Raspberry Pi Camera
Published 2019-08-01
Intro To 'chroot' Command In Linux
Published 2023-06-23
Join My Mailing List

Privacy Policy
Why Bother Subscribing?
  • Free Software/Engineering Content. I publish all of my educational content publicly for free so everybody can make use of it.  Why bother signing up for a paid 'course', when you can just sign up for this email list?
  • Read about cool new products that I'm building. How do I make money? Glad you asked!  You'll get some emails with examples of things that I sell.  You might even get some business ideas of your own :)
  • People actually like this email list. I know that sounds crazy, because who actually subscribes to email lists these days, right?  Well, some do, and if you end up not liking it, I give you permission to unsubscribe and mark it as spam.
© 2025 Robert Elder Software Inc.
Privacy Policy      Store Policies      Terms of Use