Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have installed cowsay and fortune. I want to set my own talks or texts in cowsay. But I can't configure it out. When I open terminal there is nothing from cowsay. I want to show cowsay when I start terminal.

But this works:

hash@ssl50:~$ cowsay -f tux "Carry on"

< carry on >
       |o_o |
       |:_/ |
      //   \ \
     (|     | )
    /'\_   _/`\
share|improve this question
up vote 7 down vote accepted

Well, in Linux Mint there is a fun thing you could do: write a script to select a cow and display a message from fortune. I'll get to it later. Once you have the script, all you have to do is to execute it. As suggested before, edit your ~/.bashrc file and add at the end a line containing the path to your script. For example, if you have the script in your home folder and the script's filename is "cowscript", then you could add the following line at the end of your ~/.bashrc file:


Now, the script used in Linux Mint 9 is the following:


let "number %= $RANGE"
case $number in

let "number %= $RANGE"
case $number in
/usr/games/fortune | $command -f $cow

Basically, it will display a random cow (either small, tux, koala, or moose) and the message will be taken from fortune. Also, this script will execute wither cowsay or cowthink, the only difference being that cowthink will display a thinking cow instead of a talking cow.

Now, the fun thing is that you can modify the script to show more cows or to show different cows. To do that, you first need to know what cows you have installed. In a terminal, run:

cowsay -l

You can use any of those cows. All you have to do is to edit the script: if you want to add a new cow, just copy the lines containing "cow" (plus the number and semi-colons) and paste them before the line that says "esac". Then, change the number and name of the cow, so for instance, if you want to add a cow called "udder", all you have to do is to add these lines before the first "esac":


Important: the second line of the file, "RANGE=4", must be changed also. If you add one cow, then instead of 4 use 5, also if you delete one cow, then you must use 3, and so on. Also note that the numbers that you see must be in the range from 0 to RANGE - 1. That's why RANGE is 4 and the numbers are 0, 1, 2, and 3.

You could also create your own cows, although that might take a bit more of work. All you have to do is to get any ASCII art you like and edit it, but it is a bit tricky. You can see how it's done here: However, consider that any @ and \ symbols need to be backslashed, that is, you must put before that symbol this other symbol: \. This might be the case for #, too (but not always). If your ASCII Art contains #, you could backslash it too, but sometimes it would be enough with just one of them... I'm not sure how to explain it, sorry. I guess you will have to try to see if it works. Also, make sure that the file you edit has the extension ".cow"

Finally, once you have your own cows, you can either add them to the default location (you probably will need to be superuser for that) at /usr/share/cowsay/cows, or you could add to your ~/.bashrc file this lines:

export COWPATH="/usr/share/cowsay/cows"
# set COWPATH so it includes user's cows
if [ -d "$HOME/cowfiles" ] ; then

Be sure to add those lines before you call your "cowscript". This also assumes that you have a folder called "cowfiles" on your home folder. Change the path if you want so it points to the folder where you have your cowfiles.

share|improve this answer

If you want to combine cowsay and fortune to present you with a message each time you start a terminal, add the following line:

fortune | cowsay -f tux

to the file .bashrc in your home folder.

Package shortcuts: cowsayInstall cowsay fortuneInstall fortune

share|improve this answer

cowsay command line with random cowfile:

fortune | cowsay -f `ls /usr/share/cowsay/cows/ | shuf -n 1`


/ Q: Who cuts the grass on Walton's \
\ Mountain? A: Lawn Boy.            /
   \ ,   _ ___.--'''`--''//-,-_--_.
      \`"' ` || \\ \ \\/ / // / ,-\\`,_
     /'`  \ \ || Y  | \|/ / // / - |__ `-,
    /@"\  ` \ `\ |  | ||/ // | \/  \  `-._`-,_.,
   /  _.-. `.-\,___/\ _/|_/_\_\/|_/ |     `-._._)
   `-'``/  /  |  // \__/\__  /  \__/ \
        `-'  /-\/  | -|   \__ \   |-' |
          __/\ / _/ \/ __,-'   ) ,' _|'
         (((__/(((_.' ((___..-'((__,'

You can add this command line to end of your login profile script for seeing random cowsay in any terminal. For bash, you would need to put this line in ~/.bashrc.

To make it also randomly choose between cowsay and cowthink, you can do this:

fortune | `ls /usr/games/cow* | shuf -n 1` -f `ls /usr/share/cowsay/cows/ | shuf -n 1`

This allows to have a one-line solution with random cowfiles, instead of painstakingly extending the Linux Mint script.

share|improve this answer
This is perfect! Exactly what I wanted. – landroni Nov 17 '14 at 7:32
You need to install both cowsay and fortunes to make this work. – landroni Jan 16 '15 at 7:24
That is genius!! Thanks for the one liner :P :) – codeMan Apr 16 '15 at 6:55
+1 This is gold! Had to add an additional sed: fortune | cowsay -f `ls /usr/local/share/cows/ | sed "s/.cow\*//g" | shuf -n 1` (Cygwin). – prakharsingh95 Jul 19 at 17:39

I used the first two answers and the man page to get a turtle's random thought's.

  1. Found the cowsay -l switch to list all of the cowfiles.
  2. After finding the turtle, I edited my ~/.bashrc.

    fortune | cowsay -f turtle

P.S. I suggest that your first step is.

$ sudo apt-get install fortune-mod fortunes-ubuntu-server fortunes-off fortunes-bofh-excuses fortunes-debian-hints fortunes-spam cowsay

That way you will have plenty of fortunes. These fortunes also come in handy if you have "Wanda the wise Gnome fish" installed / possibly set to autoRun.

Also a great fortune set is the mint fortunes-husse.deb package. So either find the .deb file on-line via a quick Google or add the Mint repositories to Ubuntu.

share|improve this answer

Well the right command is:

root@bt:~# cowsay -f tux "hello my name is ubuntu"

More info can be found here.

share|improve this answer
This answer just duplicates what's already in the question. -1 – Scott Severance Sep 27 '12 at 4:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.