Display Random Quotes From Commandline In Linux

Display Random Quotes From Commandline In Linux

Working from commandline in Linux is fun. We can do anything from Terminal, even we can motivate ourselves too. Here is two simple bash/zsh shell scripts to display some random quotes from popular authors, and leaders on your Terminal. These scripts will work on any system that supports bash or zsh. In this brief guide, we will discuss how to install ‘motivate’ and ‘fortune’ programs to display random quotes from commandline in Linux.

Motivate – A Shell script to display random quotes

It is highly influenced by popular linux command ‘fortune’ which displays random poignant, inspirational, motivational phrases and quotes in Terminal.

You need to install the following prerequisites before using ‘motivate’ command.

  • git
  • python3

The above two applications are available on the default repositories of most modern Linux operating systems.

For example, to install git and python 3 on Arch Linux, run:

sudo pacman -S git python3

On Debian, Ubuntu, Linux Mint:

sudo apt-get install git python3

On RHEL, Fedora, CentOS:

sudo yum install git pythin3

On suse, openSUSE:

sudo zypper install git pythin3

Once you have installed above prerequisites, git clone the ‘motivate’ repository using command:

git clone https://github.com/mubaris/motivate.git

Sample output would be:

Cloning into 'motivate'...
remote: Counting objects: 44, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 44 (delta 0), reused 0 (delta 0), pack-reused 40
Unpacking objects: 100% (44/44), done.

The above command will clone the contents of ‘motivate’ in a directory called ‘motivate’ in your current working directory. Go to the ‘motivate’ directory:

cd motivate

Compile and install ‘motivate’ program as shown below.


Run the following command to take effect the changes.

source ~/.bashrc

motivate program has been installed now. Now, let us have some fun from Terminal.

To display any random quotes, just run the following command from your Terminal.


Sample output:

"What matters is the value we’ve created in our lives, the people we’ve made happy and how much we’ve grown as people."
 --Daisaku Ikeda

Keep running this command to get more quotes. Here is some quotes displayed by ‘motivate’ command from my Terminal in Arch Linux.

To update the database, clone the motivate git repository:

git clone https://github.com/mubaris/motivate.git

Then, go to the motivate directory:

cd motivate

And, update it using command:


That’s it.

fortune – Display random quotes

Like said already, Motivate program is highly influenced by ‘fortune’ command. You can display random quotes, funny phrases, and popular adages using ‘fortune’ command too.

To install it on RPM based systems, run:

sudo yum install fortune

On DEB based systems:

sudo apt-get install fortune

Once you installed it, run ‘fortune’ on your Terminal to get random quotes and thoughts of popular people.


Sample output would be:

Behind every argument is someone's ignorance. 
-- Louis Brandeis

Automatically display quotes when you open Terminal

motivate and fortune can automatically display quotes, funny sayings, adages whenever you open Terminal application. To do so, you need to add the motivate or  fortune command to the profile configuration file of your preferred shell:

You need to do if you BASH shell:

sudo nano ~/.bashrc

Add the following lines for fortune command:

# ~/.bashrc

For motivate command, add the following lines:

# ~/.bashrc

Save and close the file. And type the following commands to take effect the changes.

source ~/.bashrc

And, That’s all. Have fun! I will be soon here with another interesting guide. Until then, stay tuned with OSTechNix.



Thanks for stopping by!

How can I benefit from this blog:

Have a Good day!!

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.