Bash fun

Monday, June 15th 2009, 22:46

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:

17 Comments

1 2
  • Cool stuff :P 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 :P

  • Actually, I think it would be more fun to do something like:

    [radu@WL-500W root]$ cowsay -f sodomized "I see you behind this cow!" > /dev/pts/1
     ____________________________
    < I see you behind this cow! >
     ----------------------------
          \                _
           \              (_)
            \   ^__^       / \
             \  (oo)\_____/_\ \
                (__)\       ) /
                    ||----w ((
                    ||     ||>>

    with the amendment that you should use another user’s console.

  • [...] Later edit: the fun continues here! [...]

  • 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!

    • Why would you like to run it as root? The answer to this is that cowsay and fortune are not in the $PATH variable for root.

      radu@tux:~$ echo $PATH
      /opt/soapui/bin:/opt/maven/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/usr/bin/X11:/usr/games
      radu@tux:~$ sudo -i
      root@tux:~# echo $PATH
      /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin
      root@tux:~# cowsay
      Command 'cowsay' is available in '/usr/games/cowsay'
      The command could not be located because '/usr/games' is not included in the PATH environment variable.
      -bash: cowsay: command not found

      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/games or you just use Tudor’s way of doing this described in his first comment.
      Have fun!

  • 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)

  • 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 :)

    • Tudor said sudo su. If you use sudo -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:

      root@tux:/home/radu# cowsay -f sodomized I see you behind this cow! > /dev/pts/0
       ____________________________
      < I see you behind this cow! >
       ----------------------------
                            _
                           (_)
                 ^__^       / 
                 (oo)_____/_ 
                  (__)       ) /
                      ||----w ((
                      ||     ||>>

      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…

  • 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 :D

    • Try man sudo and see the difference between those options. If you try to use sudo as root, well that’s not possible. sudo is meant only for users other than root, but they must be in the sudoers list. If you have tried sudo as 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/hostname and /etc/hosts.

  • 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:

    aptitude install sudo 
    No /etc/sudoers found... creating one for you.

    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)

    cat /etc/hostname

    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:

    PTy990499a:~# cat /etc/hostname
    PTy990499a.servername.com
    PTy990499a:~# cat /etc/hosts
    127.0.0.1       localhost
    200/66.123.66   PTy990499a.servername.com.servername.com  PTy990499a
     
    # The following lines are desirable for IPv6 capable hosts
    ::1     ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts

    (*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 :D
    Thank you again Radu!

  • 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 :D
    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! :D

  • I’m back with a working sudo :D
    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 :D

    • Yeah… I’ve got two ideas. First issue who in 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. :P

1 2

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">


CODE EXAMPLES: When you want to include source code or terminal output, please use the the following tags like in the next example:

    [language]
    code lines
    [/language]
	

where you substitute language with the programming laguage used throught the code example (for terminal output that would be bash), e.g:

    [bash]
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    [/bash]
	

To see a list of all the supported languages, please check this page.

If you want to include code bits inline, please use the code tags like in the following example:

    The <code>$USER</code> variable holds the current logged in username.
	

Secure your files

Dropbox

Recent Comments

  • Radu said:
    After you install VMware Server there is no menu entry for it. To access its interface you should open a browser tab and go to... more»
  • Radu said:
    I bought mine just a month before they launched the 3rd generation. But it’s really okay for my needs. more»
  • Radu said:
    Something must have gone wrong during the install process. Try to reinstall the drivers (after you have uninstalled them previously)... more»
  • Radu said:
    I think you should start Firefox (due to the fact that the plugin runs under it) with that custom wrapper script. more»
  • RGG said:
    As with Mai I removed vmnet, vmci and vmmon. Ran sudo vmware-config.pl and it reran the last part of the install but did not add any... more»

Recent Tweets

Geek blogs

Bear