The yes command in Linux is often underrated, but it can be quite useful when combined with other tools in a pipeline. It automatically outputs a string repeatedly—by default, “y”—and this can be piped into commands that require user confirmation. This can be especially handy in testing, automation, or scripting. For example, when installing packages, you might use yes to bypass the confirmation prompt. For more on scripting and system setup, check out our guide on how to install Kernel 6.15 on Ubuntu.
However, it’s important to note that yes is not always the ideal solution. When available, it’s better to use the appropriate flags that make commands non-interactive (like -y or --assume-yes). This method is safer and more reliable, especially in production scripts. Blindly piping yes into commands can lead to unexpected consequences if those commands prompt for destructive actions. For more efficient scripting practices, explore tools like grep tricks for ps or understanding symbolic and hard links in Linux and Unix.
Practical Examples of the yes Command
Here are 5 practical examples of how yes can be used effectively:
- Force installation without prompts (when
-yis not available):yes | some-legacy-installer - Stress-test a custom script that loops on confirmation:
yes | bash -c 'while read line; do echo $line; done' - Generate large files of repetitive text (for testing I/O):
yes Testing123 > bigfile.txt - Accept license terms in an interactive installer:
yes | ./install.sh - Simulate constant input for program debugging:
yes y | some_program
Use with Caution
Despite its usefulness, yes should be used with caution. In most modern Linux utilities, there’s a better alternative: using official flags to disable prompts. For example, instead of:
yes | sudo apt install gimp
You should use:
sudo apt install -y gimp
This ensures clearer, safer, and more maintainable scripts. Use yes when you’re dealing with legacy tools, or for fast experiments—not for critical automation.
yes is simple but powerful—just be mindful of where and how you use it.






Pingback: Open Files and Directories from the Terminal with Ease - iDoLinux
Pingback: Open Files and Directories from the Terminal with Ease - Open Source Software News