The terminal is a very powerful tool, and it’s probably the most interesting part in Unix. Among the plethora of useful commands and scripts you can use, some seem less practical, if not completely useless. Here are some Bash commands that are fun, and some of them are useful as well.
Let’s check them out.
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, and even the month, that you want as an argument. 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. sl
This one stands for “Steam Locomotive” and is often typed in error (as it is the opposite of ls
). Judging how boring visuals are on the terminal, it is cool to periodically see a locomotive on your terminal, especially when you did not mean for it.
First, install sl
with this command typed in your terminal:
sudo apt install sl
Then type the command:
sl
3. yes
A very peculiar command with only one ability: repeating a string until its process is killed. This command displays a string for an infinity until the command is killed. Just type:
yes <string>
For example, yes I did it
.
Don’t forget to press Ctrl + C to stop it, or it will run forever.
While it may seems useless, the yes
command is very handy when you are running scripts that wait for prompts that you need to automate. For example:
yes y /path/to/script
will give a “y” when a prompt asks for a “y/n” answer.
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” It’s pretty strange, I know.
rev
Enter an interactive mode and can quit by using the shortcut Ctrl + C. But rev can also work to reverse an entire file with:
rev [path of the file]
5. aafire
Ever wondered what fire would look like on the black interface of the terminal? This can be achieved with the aafire
command.
The first step is to install aafire with the following code on your terminal:
sudo apt install libaa-bin
Once it has been installed, on your terminal type:
aafire
6. espeak
If you are tired of hearing the everyday voices around you, this command could be your escape. You can listen to your computer talk by installing espeak
using this command:
sudo apt install espeak
After, run espeak using the command:
espeak "Type what your computer says"
Note that whatever you type within the double quotation marks is what your computer will say.
7. 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 your own.
figlet [-f path to the font] [string]
For example:
figlet Welcome
8. Banner
Similar to figlet, display the text in a big banner format. Install it with the command:
sudo apt install banner
and use the syntax:
banner your text here
9. cowsay
This script basically displays a cow character using ascii symbols the arguments passed to it. First, install cowsay with this script:
sudo apt install cowsay
Then type in the terminal:
cowsay yourtext
Note: replace “yourtext” with whatever text you need to be displayed by the cow.
If you prefer a colorful pony to a cow, you can install the ponysay
package and its respective command:
ponysay yourtext
10. Cowthink
This command is similar to cowsay
, with the only difference being the output is displayed as a thought. To use this command, just type:
cowthink <whatever you need to be thought>
For example:
cowthink Hmm, I didn't know that
11. 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 install fortune
It comes with a very handy option: -s
for short, which will limit it to fortunes composed of one sentence or less.
fortune [-s]
12. Oneko
This command adds some spice to your terminal by adding a cat to your screen which will chase after your (mouse) cursor. Install it by running this script:
sudo apt install oneko
Type oneko
to display the cat.
13. Dog
There is a cat
command, and “dog” is an alternative to “cat.” (See the humor?) It uses the same syntax to display a text stream into the console. You will probably have to install it, as it is not a command offered by default, but when you do, take a look at the manual page.
14. cmatrix
If you have seen the Hollywood movie Matrix, then you will relate easily to this command. Install cmatrix using the script:
sudo apt install cmatrix
Run it by typing cmatrix
in your terminal.
15. time cat
This is actually two commands time
and cat
used together. You can use this 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. To launch it, just type:
time cat
16. factor
It’s time to do some Math. Let’s do an easy one with the command factor
which can break down a given number into prime factors:
factor [number to decompose]
17. w
You can say whatever you want about “w,” but it is to my knowledge the shortest command you can find by default on your machine. Therefore, it deserves to be in our list just for that. “w” allows you to see information about current users, like their name, login time, etc.
Conclusion
We, of course, know how important commands are, especially in a Linux terminal, but once in a while it is nice to take a break and just amuse yourself with these fun commands.
Our latest tutorials delivered straight to your inbox