Linux Commands

How To Use cowsay Linux Command

Not all terminal commands execute productive tasks. Some are there for fun and to put a smile on your face. An example of this command is the cowsay Linux command. Just from the name, cowsay is a configurable talking cow. Yes, you heard that right: a command that imitates a talking and thinking cow. There are different ways to play around with cowsay. The cowsay takes text input and displays a speech bubble of the text.

How To Install cowsay

The cowsay utility command is available on the package manager, and you can install it with the following command:

$ sudo apt-get install cowsay


There are different options to use with cowsay. You can start with a welcome message, as shown below:

$ cowsay Hi, welcome.

You can use different flags to play around with the cowsay. For instance, you can use the “-e @@” options to add wonky eyes to the cow. To make the cow stick out its tongue, use the “-T U” options. The “@@” are characters, and you can replace them with any character that fits your cow’s eyes.

Listing Available Art Types

There are different art types that you can use with cowsay. To view the complete list, use the “-l” option.

$ cowsay -l

You can also list all the cow art types using the following command:

$ ls /usr/share/cowsay/cows/

You can use any of the art types in place of the cow. For instance, let’s play with the turkey to see the output. To select an art type, use the “-f” option.

$ cowsay -f turkey "Well, I am a talking turkey!"

You can choose any art type, which will display with the input words you give. Moreover, it’s possible to print a pretty cow or any art type saying text from stdin. Combine cowsay with echo.

$ echo "I need water!" | cowsay -f dragon-and-cow

Different cowsay Mind States

As we’ve seen, the cow can say any message fed to it. However, you can also add different states of mind to create more entertainment. There are eight states of mind that you can use. Let’s see some examples.

1. Paranoia

If you want to depict the paranoia mode of the cow, use the “-p” option.

$ cowsay -p <message>

2. Dead

A dead state of mind of the cow shows “XX” and can be depicted using “-d”.

$ cowsay -d <message>

3. Borg Mode

A Borg mode is represented by the “-b” option.

$ cowsay -b <message>

4. Wired

For a wired state, use “-w”.

$ cowsay -w <message>

5. Youthful

The “-y” shows an energetic and youthful state of mind.

$ cowsay -y <message>

6. Tired

Even cows get tired. You will have a tired cow using the “-t” option.

$ cowsay -t <message>

7. Greedy Mode

The greedy mode, “-g”, adds dollar signs in the cow’s eyes.

$ cowsay -g <message>

8. Stoned

For a stoned state, use the “-s” option

$ cowsay -s <message>

Combining cowsay With Fortune

Using the fortune utility that prints fortune messages, you can add more fun to your cowsay. If you don’t have fortune installed, use the following command:

$ sudo apt install fortune-mod

Instead of adding the input text, pipe the fortune output to cowsay.

$ fortune | cowsay

Now, you have your pretty cow speaking your fortune message. Amazing!

Even with fortune, you can still play around with different art types.

$ fortune | cowsay -f dragon

Conclusion

When you work with Linux and need a break, playing with cowsay is an option. The utility lets you create different cowsay art and define which message and state of mind they should give. Furthermore, we’ve seen how you can combine cowsay with the fortune utility to spice the fun. With the examples above, you should be able to create your art and play with the available options. Get creative and have fun!

About the author

Denis Kariuki

Denis is a Computer Scientist with a passion for Networking and Cyber Security. I love the terminal, and using Linux is a hobby. I am passionate about sharing tips and ideas about Linux and computing.