Open In App

Cool Custom Welcome Messages on Linux terminal

Improve
Improve
Like Article
Like
Save
Share
Report

There is a Linux hack which can be used to display a custom message on the terminal every time we open it. This can be done by manipulating the .bashrc shell script.

What is .bashrc ?

It is a shell script that Bash runs whenever it is started interactively. You can put any command in that file that you could type at the command prompt.

Steps on how to do it :

  1. Firstly, open the terminal and open the ./bashrc file using any editor of your choice. (Here, vim is used) .
    vim ~/.bashrc
    

    The file will open in vim editor as shown in the figure below:

  2. Now, add a small line(shown below) at the beginning of ~/.bashrc and save the file and exit.
    echo "Welcome MAZHAR"
    

    Now, close the terminal and open a new terminal, you will see the message as shown below:

    YOU ARE DONE 🙂

There is one another interesting way to do it It can be done by the combination of two command-line tools:

fortune and cowsay
fortune: This prints out a random interesting proverb.
cowsay: This utility displays a speaking cow in terminal window.

Let’s see how to do this:

  1. On Ubuntu or Linux mint, install the fortune cowsay as follows:
    sudo apt-get install fortune cowsay
    
  2. Now, open the terminal and open the ./bashrc file using any editor of your choice. (Here, vim is used)
    vim ~/.bashrc
    
  3. Now, add a small line(shown below) at the beginning of ~/.bashrc and save the file and exit.
    fortune | cowsay -pn
    
  4. Now, close the terminal and open a new terminal, you will see the message as shown below:

    Amazing!!! Isn’t it. You are done.

More Examples

Now, once fortune and cowsay is installed, by adding different parameters, different cool beings can replace the cow.
Lets see each of them one by one:

  1. Showing a Tux : add -f tux with fortune | cowsay and save and exit.
    fortune | cowsay -f tux
    

    Now, open a new terminal and see the tux appearing with a message as shown below:

  2. Showing a stegosaurus : add -f stegosaurus with fortune | cowsay and save and exit.
    fortune | cowsay -f stegosaurus
    

    Now,open a new terminal and see the tux appearing with a message as shown below:

  3. Many Linux terminal commands can also be piped with cowsay such as ls command.
    For example: Type the following command in the terminal to show the contents of a directory as the fortune message.

    ls | cowsay -f stegosaurus
    

    Here is the output:

  4. One can also show a custom text as the fortune message .
    Type this command in the Linux terminal

    cowsay -f tux "GeeksForGeeks Technical Scripter Event"
    

    Here is the output:

Reference: Wiki


Last Updated : 31 Jan, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads