How to Use Cowsay Command on Linux

The cowsay command on Linux is a fine example of interactive coding while having fun. Here’s everything you need to know about the cowsay command and some fun ones for you to try out right now. 

The cowsay is a program (in our case, is a command) that generates ASCII art pictures of a cow with a given message. You heard it right, it’s a fun command that accepts a text string and outputs a graphical text on Linux of cow talking. 

This command also generates talking of any animal if you provide a premade picture, and the program is written in Perl. A cowfile is the main file executed by the program. It is made up of a simple block of Perl code, which automatically assigns a picture of a cow to the variable [$the_cow]. 

Prerequisite

For this command to run, you need a Linux-based OS. That’s it.

Installing cowsay command on Linux

You can easily install cowsay package on Debian, Ubuntu, Mint, and many other Linux OS with the following command:

$ sudo apt install cowsay

As always, you are required to have sudo privileges to install any package. So make sure you have one.

Listing Art Types Available

There are different art types other than a cow, like a dragon, penguin, duck, etc. You can use the following command with the -l flag.

Input:

$cowsay -l

Output may look like this:

cowsay command on linux

As you can see, there are many options available like bunny, dragon, dragon-and-cow, and elephant.

Choose an Art Type

Above, we listed out all the possible art types. To select and use one, you can use -f option followed by the art name and message.

Syntax:

$ cowsay -f [art_type] “<message>”

Example:

$ cowsay -f turkey “Hi, I am talking turkey :)”

You can use any of the available art in your inventory.

Choosing Different Mind States 

As we can see in the above example, the cow says any message we give. However, you can add other states to make it more entertaining. There are in total eight states of mind you can use and we’ve listed them all here.

1. Paranoia (Paranoid)

cowsay command on linux

In this mode, “@@” replaced the normal cow eye. The normal cow has “OO” in the eye, as you can see above. To achieve this mode, you can use the -p flag.

Syntax:

$ cowsay -p [message]

Example:

$ cowsay -p “My paranoia mode”

2. Dead

cowsay command on linux

In this mode, the eyes of the cow are replaced with “xx” and its tongue sticking out with the “U” keyword. To achieve this, you can use the -d flag.

Syntax:

$ cowsay -d “[message]”

Example:

$ cowsay -d “Not okay”

3. Borg Mode

borg mode

This mode is also a fun one. In this mode, normal cow eyes are replaced with “==” sign. You can use the -b flag followed by a message you want to display.

Syntax:

$ cowsay -b “[message]”

Example:

$ cowsay -b “borg mode”

4. Wired Mode

wired mode

Here, “OO” is used as cow eyes. You can use the -w flag to achieve this mode.

Syntax:

$ cowsay -w “[message]”

Example:

$ cowsay -w “wired me”

5. Youthful Mode

youthful mode

This mode tries to show the youthful mind of a cow by replacing normal eyes with the “..” keyword. That kinda looks funny. You can achieve this using the -y flag.

Syntax:

$ cowsay -y “[message]”

Example:

$cowsay -y “I feel good”

6. Tired Mode

cowsay command on linux

This mode tries to mimic a tired cow with the “- -” keyword in the eye. You can achieve this using the -f flag.

Syntax:

$ cowsay -t “[message]”

Example:

$ cowsay -t “Today I am tired”

7. Greedy Mode

cowsay command on linux

This mode shows how a cow can be greedy too. It uses “$$” in the cow eyes and you can do this too using the -g flag followed by a greedy message.

Syntax:

$ cowsay -g “ [message] ” 

Example:

$cowsay -g “Money is good”

8. Stoned Mode

stoned mode

This funky mode uses “**” in the cow’s eyes and “U” as the cow’s tongue to show that it is stoned. You can use the -s flag to achieve this mode.

Syntax:

$ cowsay -s “[message]”

Example:

$ cowsay -s  “Stoned mode”

Setting the Eye Symbol Manually

You can also specify which type of symbol to use in cowsay command, and it can replace default eyes with the kind you specify manually. All you need to do is use the -e flag followed by eye type. 

Syntax:

$ cowsay -e [eye_type]

Example:

$cowsay -e ^ ^

Setting the Tongue Shape Manually

As we did above with the eyes, we can also manually set tongue shape with the -T flag followed by tongue string. 

Syntax:

$ cowsay -T [tounge_string]

Example:

$ cowsay -T \(\)

Don’t Wrap Word

This command disables the wrapping of words. If you type long texts with a cowsay command, they can be wrapped if they are long. With this -n flag, line break does not happen.

Input:

$ cowsay -n [text]

Example with Different Art Types

First list all the available art types like this:

$ cowsay -l
cowsay command on linux

Now we’ve chosen something random, Vader. Come to the dark side and try out this code, which is a lot of fun too. 

Input:

$ cowsay -f vader [your_message]
cowsay command on linux

Let’s try one more, the dragon breathing fire, all in code!
Input:

$ fortune | cowsay -f dragon
cowsay command on linux

Cowthink command

It is very similar to cowsay but this command tries to mimic that a cow or any other art type is thinking something. 


A bubble leading towards a cloud-shaped message looks fun. 

Syntax:

$ cowthink [message]

Example:

$ cowthink hi, This is cowthink
cowthink

Now, you have a cow giving everything hard thinking with a cloud bubble right over it. 

Going on and on with coding on Linux can be stressful, which is where the cowsay command brings you a sigh of relief, while still sharpening your coding skills! All the art types and modes mentioned above are also supported in cowthink command. 

If this guide helped you, please share it.

Leave a Reply
Related Posts