General

Let’s Have Some Fun With Cowsay And Fortune

Today, we’ll be having fun with ‘cowsay’ and doing so while getting your fortune in your terminal. Why not? Linux doesn’t always have to be about work. Today’s article will be not even remotely useful for work and none of what you learn will greatly increase your Linux skills. We are doing this for fun, mostly.

Sometimes, it’s okay to be a little silly and to have some fun.

Besides, you’ll get to use the | (pipe) and that’s always fun! Seriously, the pipe is one of the best tools Linux has. It lets you take the output from one command and use it in another one. The man page helpfully describes it like this:

pipe – Postfix delivery to external command

We’ll just be scratching the surface with pipe, so be sure to run man pipe if you’re unfamiliar with it. Pipe hails from Unix and has been with us, in one form or another, since 1973. I dare say that the longevity is good evidence of the value.

I’m just going to give the directions for Debian/Ubuntu/derivatives. I haven’t checked across all the systems, so I’m not sure what distros this will work on. Probably all of the major distros, but it should work on anything with Debian in its lineage. If you’re not doing so, you should still be able to follow along and just adapt it to your package management systems. 

So, that being said and done, let’s look into this matter of a mad world with cows and fortunes.

Fun With Cowsay:

The first thing we have to do is open a terminal. Press CTRL + ALT + T on your keyboard and the default terminal emulator should open up. Once open, run the following command:

sudo apt install cowsay fortune

That should install both ‘cowsay‘ and ‘fortune‘, along with any dependencies that need to be satisfied. Those are the only two tools you need to install for this exercise, or at least they should be.

Fortune:

Fortune is a tool that outputs fortunes from a database. A normal use would be:

fortune

That should happily output a fortune for you.

Cowsay:

The cowsay application prints a graphic that looks vaguely cow-like and any text you tell it to print. The command would look a bit like this:

cowsay moo linux-tips.us moo

All of which is all well and good – but the magic is when you put them together. So, let’s try that. Let’s pipe fortune output to the cowsay application:

fortune | cowsay

Which will have an output similar to this:

See? You’ve got a cow spouting wisdom in the terminal! Just what you always wanted!

That’s not it! No, dear reader, that is not it! That’s not all you can do! See, you can change the cow to Tux, the Linux penguin mascot.

What the penguin has to do with a cow, I know not. But, I do know that you can use the command and output a penguin. 

fortune | cowsay -f tux

The output from that command should look pretty similar to this:

See? It’s Tux! I wouldn’t make this sort of stuff up. It’s too important!

And there you have it. You’ve successfully piped the output from fortune to cowsay and, as a bonus, morphed the cow into tux. Another productive day at the office, while having fun with cowsay!

Closure:

I’ve got a couple of articles ahead, which is nice. This one tells you how to have fun with cowsay, which is also nice. It’s pretty important business!

Now to write some that are scheduled years in the future (so that I don’t mistakenly post them and they’re out of the way) and not fret too much when Mother Nature comes to claim my internet… I’m not giving up on my publishing schedule yet!

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

Recent Posts

Enable/Disable Your Network Interface

Today we'll cover one way to enable or disable your network interface in the Linux…

5 months ago

Check Your NIC Speed In The Terminal

Today's exercise is a nice and simple exercise where we check your NIC speed in…

5 months ago

Easily Monitor Your Wireless Connection

Have you ever wanted to easily monitor your wireless connection? Well, now you can learn…

6 months ago

Count The Files In A Directory

I think I've covered this before with the ls command but this time we'll count…

6 months ago

Get System Information With The ‘uname’ Command In Linux

Today we'll be learning about a basic Linux command that's known as 'uname' and it…

6 months ago

hardinfo Has Been Rebooted As hardinfo2

If you've used hardinfo in the past, it may interest you to know that hardinfo…

6 months ago