Bash fun
Posted on June 15th, 2009 at 22:46, in Linux, Ubuntu.
Linux is awesome. I knew that! When you are completely bored and you have access to a terminal (and you are in the sudo-ers group) you can do this:
radu@enterprise:~$ sudo apt-get install cowsay Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: filters The following NEW packages will be installed: cowsay 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 0B/19.8kB of archives. After this operation, 295kB of additional disk space will be used. Selecting previously deselected package cowsay. (Reading database ... 173410 files and directories currently installed.) Unpacking cowsay (from .../cowsay_3.03-9.2_all.deb) ... Processing triggers for man-db ... Setting up cowsay (3.03-9.2) ...
Afterwards you could issue a command like this:
radu@enterprise:~$ fortune | cowsay -n -f tux.cow
__________________________________________________________________________
/ In the first place, God made idiots; this was for practice; then he made \
| school boards. |
\ -- Mark Twain /
--------------------------------------------------------------------------
\
\
.--.
|o_o |
|:_/ |
// \ \
(| | )
/'\_ _/`\
\___)=(___/
Or, if you have a sick humor:
radu@enterprise:~$ fortune | cowsay -n -f sodomized.cow
________________________________________________________
< You will have domestic happiness and faithful friends. >
--------------------------------------------------------
\ _
\ (_)
\ ^__^ / \
\ (oo)\_____/_\ \
(__)\ ) /
||----w ((
|| ||>>
Let me see how do you have that fun in Windows, suckers!
Similar Posts:
- Fortune and Pidgin’s status on Ubuntu (Linux)
- Python and Pidgin’s status on Ubuntu (Linux)
- Adobe Reader in Ubuntu
- How to install Oracle Database 10g XE and OC4J on Ubuntu
- Booting Ubuntu from an USB stick



17 Comments
Tudor said
on June 18th, 2009,
at 14:45 hours
Cool stuff
But not as cool as
sudo su
cowsay -f tux “I see you” > /dev/pts/0
where /dev/pts/0 is another dude’s console
Radu said
on June 18th, 2009,
at 14:52 hours
Actually, I think it would be more fun to do something like:
with the amendment that you should use another user’s console.
How to have fun with your Linux server :: Fun with cowsay under Linux | Tudor Barbu's professional blog said
on June 18th, 2009,
at 14:55 hours
[...] Later edit: the fun continues here! [...]
cowcant root said
on July 23rd, 2009,
at 10:38 hours
I have can do both cowsay and fortune as a user but not as root. Both were installed via root apt-get install cowsay fortune
But when trying either cmd as root I get:
-bash: cowsay: command not found
-bash: fortune: command not found
any ideas?
Thank you!
Radu said
on July 23rd, 2009,
at 11:22 hours
Why would you like to run it as root? The answer to this is that
cowsayandfortuneare not in the $PATH variable for root.So the answer is either you do not use root for cowsay (I really do not see the point of doing this), either you add in the $PATH variable for root the folder
/usr/gamesor you just use Tudor’s way of doing this described in his first comment.Have fun!
cowcant root said
on July 23rd, 2009,
at 12:34 hours
Forgot to say I use Linux Debian 5.0.1 Lenny.
Newbie
Actually I don’t want to use it as root, (been told should never use root except when needed) but I read that I need to, to do as root to message another user logged in like this:
cowsay -f moose I see you > /dev/pts/0
This cmd gets “denied” as a user
cowsay -f sodomized “I see you” > /dev/pts/1
cowsay -f sodomized “I see you” > /dev/pts/0
These cmds gets “event not found” as a user
(though I am logged in as two different users)
cowcant root said
on July 23rd, 2009,
at 12:47 hours
Ok I retried the cmds, just an update.. if I remove the “!” in :
cowsay -f sodomized “I see you behind this cow!” > /dev/pts/1
Then I get the same error, with or without the quotes: ” ”
which is: -bash: /dev/pts/1: Permission denied
(as a user)
as su: bash: cowsay: command not found
I read Tudor had said on another post:
“PS: this requires root level access”
Thank you again
Radu said
on July 23rd, 2009,
at 14:04 hours
Tudor said
sudo su. If you usesudo -i, as I used, it won’t work. For you to send that message with the exclamation mark, you just need to remove the quotes:The first output of the sodomized cow was from BusyBox, on my router, which does not interpret the quotes like Ubuntu does.
P.S. Why are you afraid to use your email? If you use it, I wouldn’t have to approve every comment you make, only the first one registered with it. I’m not gonna sell it for spam…
cowcant root said
on July 23rd, 2009,
at 14:16 hours
Radu thank you again.
Yes re sudo su:
sudo su
-bash: sudo: command not found
For my Debian its su which I believe is the same thing, yes?
So for su can’t cowsay
and for user can’t /dev/pts/1
Maybe I am misunderstanding the ‘sudo su’ thing?
Re the e-mail, to be honest, just a habit when registering isn’t required. Sorry I didn’t realize you had to approve each time so I have put my email this time
Radu said
on July 23rd, 2009,
at 15:03 hours
Try
man sudoand see the difference between those options. If you try to usesudoas root, well that’s not possible.sudois meant only for users other than root, but they must be in the sudoers list. If you have triedsudoas a regular user and found that “error”, you either are in the case mentioned in the previous phrase, either you have broken your hostname by not keeping consistency between/etc/hostnameand/etc/hosts.cowcant root said
on July 24th, 2009,
at 09:14 hours
Thank you Radu. I didn’t know that. All along I thought su & sudo were thee same thing just different cmd’s for different OS’s. Wow ok from cowsay to fixing this lol…
After some digging I found that I didn’t have ‘sudo’ (http://www.binbash.eu/linux/58-debian-etch-notes) so I did:
Ok so now I try (as a user and as root) sudo
reply same for both:
sudo: unable to resolve host PTy990499a.servername.com(*PTy990499a.servername.com I have changed, it’s not the real server name, just similar)
simply has PTy990499a.servername.com and this hostname can not be resolved (Dns unable to resolve..). Where as the servername.com part can be resolved, correctly. And the PTy990499a part is what I see on the console on each line, for example:
(*200/66.123.66 also not the real IP)
So I’m going to try to fix this myself, please don’t give away any clues
and see if I can do this myself. Just a crazy busy day here. Will post when done or stuck 
Thank you again Radu!
cowcant root said
on July 25th, 2009,
at 05:03 hours
Sorry Radu; stuck
and very frustrated.
This is what I have done and the edited replies. I posted here: http://pastebin.com/m45312224
as worried too long for here and felt like it was ruining your nice cosway post
I’m also very nervous that I’m messing with the host files. Since I only have remote access to this box it would be impossible to fix it if it went off line because I mess something up real good.
Thank you very much!
PS. I didn’t mean to come here to have you fix all of this for me, sorry…if you want me to take it to a forum to fix, I understand
Thank you again Radu!
cowcant root said
on July 26th, 2009,
at 07:09 hours
I’m back with a working sudo
sudo /etc/init.d/apache2 reload
[sudo] password for myname:
Reloading web server config: apache2.
But cowsay still can’t speak to another user. I’ve tried a variety of cmds:
sudo su cowsay -f moose I see you > /dev/pts/2
-bash: /dev/pts/2: Permission denied
sudo su cowsay -f moose I see you > sudo /dev/pts/2
su: invalid option — f
Usage: su [options] [LOGIN]
sudo su cowsay -f moose I see you > sudo su /dev/pts/2
su: invalid option — f
Usage: su [options] [LOGIN]
sudo cowsay -f moose I see you > /dev/pts/2
-bash: /dev/pts/2: Permission denied
sudo cowsay -f moose I see you > sudo /dev/pts/2
sudo: cowsay: command not found
cowsay -f moose I see you > sudo su /dev/pts/2
(no reply, and it didn’t say to user 2)
Any ideas? Thank you
Radu said
on July 26th, 2009,
at 12:01 hours
Yeah… I’ve got two ideas. First issue
whoin a terminal to see who is logged in and where. Then do what Tudor has shown you. Afterwards maybe you can send me some money for support.cowcant root said
on July 26th, 2009,
at 13:22 hours
sorry, didn’t post that one as it brought me back to original post:
sudo su
[sudo] password for myname:
*****:/home/myname# cowsay -f tux I see you > /dev/pts/1
bash: cowsay: command not found
Sorry, can’t send you money, but can send Thank Yous’ here
(I know not the same
cowcant root said
on July 27th, 2009,
at 07:14 hours
I solved it. Thank you again Radu for your time and help. Please feel free to delete my non helpful post lol. I wouldn’t be offended.
Florin said
on May 21st, 2010,
at 22:14 hours
Having fun on windows: here’s how: http://forum.codecall.net/classes-code-snippets/13036-cowsay-c-version.html
Think you've got something to say?
For leaving comments including source code or terminal output, please use the the following tags like in the next example:
where you substitutelanguagewith the programming laguage used throught the code example (for terminal output that would be bash), e.g:To see a list of all the supported languages, please check this page.
If you want to include code bits inline, please use the
codetags like in the following example: