Option 2. Random fortune and cowsay for all users
To add random
cowsay for a all users, you need to edit
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 all users globally.
Little explanation about the code above
This code snippet is better as it checks whether
fortune exists in your system. So
Line 1 does that…
if [ -x /usr/games/cowsay -a -x /usr/games/fortune ]; then
Line 2 uses fortune and then
pipes the quote to
cowsay. But default
cowsay would only use a cow to say the quote. We are using random creatures here using
shuf -n1 to rotate files in
fortune | cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1)
And of course
Line 3 is end of the loop.
So how does it look like at the end? Here’s few screenshots:
And of course for me as a Kali Linux user, Dragon!!
Hope you find this little guide useful. Enjoy and don’t forget to share.