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

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:

timecat

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

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]

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

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]

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}; dofor j in $(seq1$i); doecho-ne$i×$j=$((i*j))\\t;done; echo;done

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'1299999| paste -sd-+ |bc-l

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.

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:

sudoapt-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]

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:

sudoapt-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]

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

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

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

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.

Receive FREE how-to articles in your Inbox!

33 comments

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.

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

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.

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

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.

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…