Install Cowsay
You can install cowsay
in Debian, Ubuntu or Kali Linux or any aptitude/apt-get based distro using the following command:
apt-get install cowsay (or) sudo apt-get install cowsay
Just like fortune, cowsay
is available in all the basic standard repositories, otherwise just add them for your respective Linux version.
Similar to fortune, you can install cowsay
in Redhat, CentOS, Fedora of any yum based Linux distros using the following command:
yum install cowsay (or) sudo yum install cowsay
If you have a different distro, the command is pretty much the same.
Type in cowsay a sentence/word
and a cow will repeat that in your terminal.
Exciting! A talking cow … Well I guess I could go and watch a movie now!
List and location of cowsay files
cowsay creatures are located here:
root@kali:~# ls /usr/share/cowsay/cows/ apt.cow ghostbusters.cow sheep.cow beavis.zen.cow gnu.cow skeleton.cow bong.cow head-in.cow snowman.cow bud-frogs.cow hellokitty.cow sodomized-sheep.cow bunny.cow kiss.cow stegosaurus.cow calvin.cow kitty.cow stimpy.cow cheese.cow koala.cow suse.cow cock.cow kosh.cow three-eyes.cow cower.cow luke-koala.cow turkey.cow daemon.cow mech-and-cow.cow turtle.cow default.cow meow.cow tux.cow dragon-and-cow.cow milk.cow unipony.cow dragon.cow moofasa.cow unipony-smaller.cow duck.cow moose.cow vader.cow elephant.cow mutilated.cow vader-koala.cow elephant-in-snake.cow pony.cow www.cow eyes.cow pony-smaller.cow flaming-sheep.cow ren.cow root@kali:~#
Random Fortune and Cowsay in Linux terminal
Now it’s time to put everything together. You have two options.
- You can add random fortune and cowsay for a single user
- You can add random fortune and cowsay for all users.
Option 1. Random fortune and cowsay for single user
To add random fortune
and cowsay
for a single user, you need to edit .bashrc
file in the users home directory.
vi ~/.bashrc
Now add the following line at the bottom of the file:
if [ -x /usr/games/cowsay -a -x /usr/games/fortune ]; then fortune | cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1) fi
Save and exit. Reopen terminal and you will see a random creature quoting a different phrase/jokes for that user.
BMO if you had a Like button. I would put like on everything I reed so far! Thanks for sharing knowledge, it’s Very usefull for begginers as me :)
That’s very kind of you. Thanks.
This script as written does not work on openSuse or Manjaro (based on Arch Linux) for two reasons:
1. The binaries for cowsay and fortune are not in /usr/games but in /usr/bin.
2. The data files for cowsay are not in /usr/share/cowsay/cows, but in /usr/share/cows.
So the script has to be changed:
if [ -x /usr/bin/cowsay -a -x /usr/bin/fortune ]; then
fortune | cowsay -f $(ls /usr/share/cows/ | shuf -n1)
fi
Thank you. I’ve only added Debian and Redhat based commands here. I’ll update the post with your comments soon.
You can also add this on your “$HOME/.bash_aliases”, which should be called from your “$HOME/.bashrc”. As long as you path is setup, it should execute independent of file location:
if [[ $(which cowsay > /dev/null) -eq 0 ]] && [[ $(which fortune > /dev/null) -eq 0 ]] ; then
cowsay -f $(ls $(cowsay -l | awk ‘NR==1 {print $4}’ | sed ‘s/://’) | shuf -n1) $(fortune)
fi
And you can also play with COWPATH if you want to do it in a different way.
Correcting my code:
if [[ $(which cowsay > /dev/null ; echo $?) -eq 0 ]] && [[ $(which fortune > /dev/null ; echo $?) -eq 0 ]] ; then
cowsay -f $(ls $(cowsay -l | awk ‘NR==1 {print $4}’ | sed ‘s/://’) | shuf -n1) $(fortune)
echo
fi
BMO, I have this question, I’ve been a windows user for many years, and is quite awkwarding to work on a OS whitout antivirus and firewall! Feels like driving whithout seatbelt (pass the expression!) I’ve tryied clamav and fgwc firewall on ubuntu but seem to not work on Kali! What’s your opinion about antivirus and firewalls for kali? Do you have any? how do you have your protect system setup?
Hmm… Interesting…!!! Thanx for Sharing man..!
Currently i am generating Random Quotes on my terminal by editing .bashrc.. it looks someting like this…
# To extract ones digit of second from system clock
#a=`date|cut -c 19`
a=`date|cut -c 18-19`
a=$((${a#0}%16))
# Array containing quotes- you can edit it to your favorite quotes
var=(” Ever tried. Ever failed. No matter. Try Again. Fail again. Fail better.
\n \t\t\t\t\t\t\t-Samuel Beckett ” “Never give up, for that is just the place and time that the tide will turn.
\n \t\t\t\t\t\t\t-Harriet Beecher Stowe ” “Our greatest weakness lies in giving up. The most certain way to succeed is always to try just one more time.
\n \t\t\t\t\t\t\t-Thomas A. Edison” “Life isn’t about getting and having, it’s about giving and being.
\n \t\t\t\t\t\t\t-Kevin Kruse” “You may be disappointed if you fail, but you are doomed if you don’t try.
\n \t\t\t\t\t\t\t-Beverly Sills” “Strive not to be a success, but rather to be of value.
\n \t\t\t\t\t\t\t-Albert Einstein” “Good or Evil is irrelevant, it’s the best story that wins!
\n \t\t\t\t\t\t\t- El_Diablo ” “Real integrity is doing the right thing, knowing that nobody’s going to know whether you did it or not.
\n \t\t\t\t\t\t\t-Oprah Winfrey” “You miss 100% of the shots you don’t take.
\n \t\t\t\t\t\t\t-Wayne Gretzky” “Truth is more of a stranger than fiction.
\n \t\t\t\t\t\t\t-Mark Twain” “People who are unable to motivate themselves must be content with mediocrity, no matter how impressive their other talents.
\n \t\t\t\t\t\t\t-Andrew Carnegie” “Creativity comes from trust. Trust your instincts.
\n \t\t\t\t\t\t\t-Rita Mae Brown” “Only those who dare to fail greatly can ever achieve greatly.
\n \t\t\t\t\t\t\t-Robert F. Kennedy” “All our dreams can come true, if we have the courage to pursue them.
\n \t\t\t\t\t\t\t-Walt Disney ” “Success consists of going from failure to failure without loss of enthusiasm.
\n \t\t\t\t\t\t\t-Winston Churchill” “For certain is death for the born,
And certain is birth for the dead;
Therefore over the inevitable
Thou shouldst not grieve.
\n \t\t\t\t\t\t\t-Bhagavad Gita”)
# Welcome message ! Edit it with your name
cuscol=’\e[0;37m’
NC=’\e[0m’ # No Color
echo -e “——————————————————————————–”
echo “**************** Welcome back El Diablo! *****************”
echo -e “${cuscol}\n${var[$a]}${NC}”
echo -e “——————————————————————————–”
################################################################
i was looking for something like what u shared.. generating those creatures and all…..
again thanx for sharing… i found what i wanted…. time for me to move on.. :D
Is there a tutorial out there to make additionalascii art and then convert those to .cow files?
can you do this on a mac command line?
On Debian 8 this works:
cowsay -f /usr/share/cowsay/cows/$(ls /usr/share/cowsay/cows | sort -R |head -1) “$(fortune )”
root@localhost:~# cowsay
bash: cowsay: command not found
What’s up,I read your blogs named “Random quotes and creatures using fortune and cowsay in Linux terminal – blackMORE Ops” on a regular basis.Your story-telling style is witty, keep doing what you’re doing! And you can look our website about proxy list.
What i do not understood is in reality how you
are no longer actually a lot more well-favored than you might be right now.
You are very intelligent. You know thus considerably on the subject of this matter,
produced me individually consider it from so many varied angles.
Its like men and women don’t seem to be interested except it’s something to accomplish with Lady gaga!
Your personal stuffs outstanding. At all times
handle it up!