10 Funny And Useless Linux Command

10 Funny And Useless Linux Command

One can never say it enough: the terminal is a very powerful tool, and is probably the most interesting part in Unix. Among the plethora of useful commands and scripts that you can use, some seem less practical, if not completely useless. I’ve selected for you a couple of commands that are useless because they are funny, but not funny because they are useless (or maybe the other way around for some). If you are searching for ASCII art, random math curiosities, or various (in)utilities, this is the best of the useless.

1. cal

Few people know this, but any Unix system comes with a built-in calendar. To access it, you can simply type:

cal

funny_commands-cal

This will display the current month. However, you can select the precise year that you want as an argument, and even the month. And to be fully useless, the option “-j” displays Julian days (the number of days from January 1). To sum up:

cal [-j] [[month] year]

2. time cat

You can use this command as a built-in timer. It will run in the background until you stop it, and will then report the time elapsed between the start and the end of its process. As useful as it may seems, it is actually quite unpractical because you cannot check its value unless you stop it. I suppose it can become handy in a very specific situation but I have trouble imagining which one exactly. To launch just type:

time cat

and to kill, use the combination “Ctrl+c”

funny_commands-time_cat

3. yes

A very peculiar command with only one ability: repeating a string until its process is killed. Again, I don’t picture where it can be useful, but who knows? The syntax is straightforward:

yes [string]

funny_commands-yes

4. rev

This command is for reversing any input (as its name suggests). When I say reverse, it means that if the input is “Linux”, the output will be “xuniL”. Pretty strange, I know.

rev

funny_commands-rev

You will enter an interactive mode. You can quit it by using the shortcut “Ctrl+c”. But rev can also work to reverse an entire file with

rev [path of the file]

5. factor

It’s time to do some Maths. Let’s begin easy with the command factor which can decompose a given number into prime factors:

factor [number to decompose]

funny_commands-factor

I haven’t tested the limits of this command yet, but it seems pretty powerful. As a side note, prime numbers and the decomposition into prime factors is actually the basis for modern cryptography and Internet security. Knowing a little bit about them is always interesting. If you want to learn more, take a look at the RSA encryption.

6. Multiplication Tables

This is actually more a script than a command but it is impossible to ignore it when talking about funny stuff you can do in a console. By using

for i in {1..9}; do for j in $(seq 1 $i); do echo -ne $i×$j=$((i*j))\\t;done; echo;done

funny_commands-multiplication_tables

The terminal will display the multiplication table, nicely ordered in columns. Incredibly useless, and pretty long to remember, but you have to admit that it looks good.

7. PI

A bit more complex, you can calculate an approximation of pi through commands using

seq -f '4/%g' 1 2 99999 | paste -sd-+ | bc -l

funny_commands-pi

This combination of commands is a little bit harder to understand, but if you really want to know, seq generates the sequence of 4/1, 4/3, 4/4 until 4/99999 (without 4/2), paste merges these lines using a delimiter, and bc does the final approximation using a math library.

8. figlet

Figlet is a command for those who love to write in ASCII art. It greatly simplifies this task as it automatically transforms any given string. It comes with a bunch of fonts, by default at /usr/share/figlet/fonts/, and you can of course add yours.

figlet [-f path to the font] [string]

Note: You will need to install “figlet” before you can use this command.

funny_commands-yes_figlet

9. cowsay

cosway is very famous in the Linux world, but this command is not always present by default in every distribution. In Ubuntu, install it with the command:

sudo apt-get install cowsay

It displays a cow in ASCII art saying whatever string you want. It comes with a couple of other characters and you can add your own. The default directory for them is /usr/share/cows/. The syntax is:

cowsay [-f path of another character] [string for the cow]

funny_commands-cowsay

10. fortune

fortune displays a random sentence, in the same spirit as fortune cookies. It is not always installed by default so you may want to add it. In Ubuntu:

sudo apt-get install fortune

It comes with a very handy option: “-s” for short, which will limit to fortunes composed of one sentence or less.

fortune [-s]

funny_commands-fortune

Combinations

The fun part is now to combine the previous commands for a funnier result. A famous combination is fortune and cowsay, which creates a cow in ASCII art telling you a random fortune:

fortune -s | cowsay

funny_commands-cowsay_fortune

My personal favorite is a random character from cowsay telling you a random short fortune:

cowsay -f "$(ls /usr/share/cows/ | sort -R | head -1)" "$(fortune -s)"

funny_commands-random_cowsay_fortune

To explain briefly, it is the same as earlier: a random fortune is pushed into cowsay, but I added the option “-f” for selecting a character. The path given is a combination of listing the files from within the default directory for the characters, random sorting of this list, and keeping only the first line.

But I suppose that you could also do something like

yes "$(figlet Linux)"

funny_commands-yes_figlet

in order to repeat a piece of ASCII art, or even

cowsay "$(seq -f '4/%g' 1 2 99999 | paste -sd-+ | bc -l)"

to have a cow telling you the approximation of pi.

As always when exploring the console, there are a lot of things that can be done (even if doing them seems very useless).

Conclusion

I tried my best to collect what I found was the funniest among the Linux commands. Retrospectively, it was pretty hard to come up with a list, since, ironically, most of the Internet is helpful for finding useful commands, not the opposite.

Can you think of more funny and/or useless commands? More combinations? Or on the contrary, a utility of those listed above? Please let us know in the comments.

Do you like what you read here?

Receive the latest update in your inbox.

33 Comments

  • johnsmith500

    I think you should research yes a bit more.
    If you are a busy system administrator, yes could be real handy when you are running scripts that wait for prompts that you need to automate. Instead of switching to that sell window/terminal/putty instance only to find your script waiting for an input, you can easily parse your input to it.

    yes | /path/to/script
    To handle (y/n) inputs

    yes [text]  | /path/to/script
    To handle custom inputs

    For example 
    yes continue /path/to/script
    If your script is asking:
    Type “continue” to proceed:
    And so on.

    Reply

    • birger

      the fsck program in early sunos versions didn’t have anything like a -y option, so it asked for confirmation before trying to fix every single error. For a badly damaged file system this could literally mean thousands of y’s to get through a first attempt. yes was very handy then (after making a backup of the damaged file system using dd of course).

      Reply

  • Pbruna

    time and cat are two commands. time takes as parameter the command you want to run, and is used to measure the time the command takes to complete.

    Reply

  • a moore

    You missed “filters”, a collection of tools for transforming text.   Try installing the filters package and then run “fortune|fudd”  or “fortune|cockney”.

    A lot of these commands aren’t useless, “rev” for example could be used to transform a DSN PTR record into a regular IP address.  Remember commands are often built to be used in scripts or as part of a chain of redirects.

    Reply

    • Adrien

      Very nice one. I guess we should rename this article “10 Funny OR Useless Linux Command” (with an inclusive or)

      Reply

  • Laxator2

    Was 12 Jan 1992 a week-end or a week day? Yes, I have to answer this kind of questions all the time when dealing with large data sets. You may find that “cal 1 1992″ is not so useless after all.

    Reply

  • Coats

    You missed “dog” –
    Manuals       

     coats#4 man dog

    DOG(1)                               User                         DOG(1)

    NAME
           dog – better than cat

    SYNOPSIS
           dog  [-AbBeEnstTuv]  [-w  cols]  [-l  lines]  [--show-all]  [--number-nonblank]
           [--no-blanks]  [--bind=port]  [--dos]  [--show-ends]   [--hang-up]   [--images]
           [--krad] [--links] [--lower] [--mac] [--number] [--no-header] [--squeeze-blank]
           [--strfry] [--sock=domain:port] [--sock-test] [--show-tabs] [--raw] [--rot=num]
           [--udp]  [--unix]  [--upper] [--show-nonprinting] [--hide-nonprinting] [--help]
           [--hex] [--skip-tags] [--oog] [--version] file | URL | -

    DESCRIPTION
           dog writes the contents of each given file, URL, or the standard input if  none
           are  given  or  when a file named ‘-’ is given, to the standard output. It cur-
           rently supports the file, http, and raw URL types. It is designed as a compati-
           ble, but enhanced, replacement of cat(1).

    Reply

  • Federico Kereki

    There’s some kind of problem with the “pi” calculation; it should produce 3.14159… and it actually shows a 7 instead of the 9 (3.14157…)

    Reply

    • Adrien

      It’s a relatively rough approximation of Pi in that case. The exact approximation with 20 digits is actually 3.14159265358979323846. I will let you find the errors.

      Reply

      • cameronhorsburgh

        In the spirit of the commands listed, don’t forget the command ‘pi’. I’m not sure if it comes standard, but it’s here on my Debian box. You just issue `pi [number] and it will calculate pi to the specified number of digits.

        Reply

  • Tim

    time can be useful.  time cat might be useless.  But that’s because cat, without input is useless. But time cat would tell you how long it takes to read that file.  Or more usefully, time make, to tell you how long it takes to compile something.  Or time factor nnn, to see just how quickly factor works…

    Reply

  • Ancurio

    Even for a normal user like me, using cp on huge amounts of files will always prompt a “do you want to replace this already existing file?”, so a piped “yes no” was extremely useful.

    Reply

  • Rogerio Pereira da Silva

    Here is a nicely formatted example of multiplication tables expanding a bit the idea given in the article:

    for num1 in `seq 1 3 10`; do for num2 in `seq 1 10`; do echo -e $(for i in `seq 0 2`; do num=`expr $num1 + $i`; echo -e $num x $num2 = `expr $num * $num2`\\t; done); done; echo; done

    Reply

  • FooBar

    Nice list, +1 for cmatrix belonging here and setting useless in brackets. Maybe jp2a, doing jpg->ascii conversion fits into here too

    Reply