Command Line

Show A Random Fortune When You Open Your Terminal

In today’s article, which should be a short one, we’re going to learn how to show a random fortune when you open your terminal. This should be pretty quick and easy, easy enough for anyone to follow. Read on, my delightful readers!

NOTE: You gotta be using bash for this, as evidenced by the use of ~/.bashrc.

Why this article? Well, I am having some connectivity issues and I want to ensure I get you a nice article while I have the connection to do so. I don’t want to count on enough time to write a longer article.

Besides, it’s another good day for a fun article. I am 99% confident that this article will teach you nothing of value! And that’s okay. It’s just you having fun – and having fun is always a good idea. So, this article will just be a bit more of that, some more fun…

First, you should read the previous article and follow the directions. That’s gonna be necessary for the next part. After all, you can’t get a random fortune when you open your terminal unless you’ve installed some software to do that. So, read this article:

How To: Display Your Fortune In The Terminal

Did you read that? Did you install ‘fortune’? Good… Now we can get into this article!

How To: Show A Random Fortune When You Open The Terminal:

Sorry about the ugly headline. Gotta optimize for Google, I guess.

This article requires an open terminal, like oh so many other articles on this site. Just press CTRL + ALT + T and your default terminal should open.

With your terminal now open, we’re going to edit the ~/.bashrc file to make it show a fortune when you open the terminal. We’ll be using nano to do so, and that’s an easy enough process.

nano ~/.bashrc

NOTE: You don’t need sudo for this, as you already own this file.

With nano opening your ~/.bashrc file for editing, you just need to scroll to the very bottom. When you get to the bottom of the file, just add the following line:

fortune

Next, you need to save the file. To save the file with nano, press CTRL + X, then Y, and then ENTER.

Now, you need to reload your bash profile. That looks like:

source ~/.bashrc

Now, that should reload the terminal and profile, showing you a ‘fortune’ quote. If you want to be really sure, or if doesn’t show you a fortune, just close your terminal and open it back up again. When you open your terminal again, it should definitely show you a fortune. See? Pretty easy! It’s darned near magical!

Closure:

And there you have it. You now know how to show a random fortune when you open your terminal. ‘Snot all that hard, now is it? If I’ve gotta bang out an article with intermittent connectivity, we might as well have fun with it! Thanks for reading and we’ll get some more serious content coming up – or will we?!? I should have decent connectivity soon. It can’t stay down forever, can it?

Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.

KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

View Comments

Recent Posts

Setting Up Coding Environments on Linux for Educational Use

With so many strong attributes, such as robustness and flexibility, Linux stands as a powerful…

9 hours ago

View Detailed Hardware Information

There are many tools for showing your hardware information and today we'll get to view…

2 days ago

How To: Install Wine In Lubuntu

Today's article isn't going to be complicated or long as we are going to cover…

4 days ago

Update Python Packages (PIP)

We've had a run of Python packages recently and you can tell that I'm a…

6 days ago

Save A Command’s Output To A File (While Showing It In The Terminal)

The title is the best I can come up with to describe this exercise as…

1 week ago

Demystifying journalctl: A Comprehensive Guide to Linux System Logging

It was suggested that I write an article about journalctl, which seemed like a large…

1 week ago