Change the Wrong Command Error Message on Linux Terminal

Ever wanted to change the default error message that pops up in the Linux terminal?
Well, it’s possible!

Should an unrecognized command be typed into the Terminal, the default message would logically enough be printed to us.

bash: <command>: command not found

Usually all the commands that can be used in the terminal regardless of the path you are currently in are located in the /bin/ folder. If you type a command that is not in the folder you are currently in, it checks if the command is available in the /bin/ folder. Should it also be missing from this location, the response would be to print out the default error message to the user.

Let’s Change it..

To change the error message, some new code would have to be added to the “bash.bashrc” file. This is located in the “/etc/” folder.
To open and edit this file you type:

sudo nano /etc/bash.bashrc

Now that we have the file open we go to the bottom and paste the following code:

# The new Error Command
command_not_found_handle () {
return 127

Once done, we need to save the file with “Ctrl+O” and then exit with “Ctrl+X”.

Now all we need to do is reboot the machine.
If done correctly the output should be as the image shows below.

Good luck!
And let the creativity burst!

NB! – NB! – NB! – NB!

DigitalBrekke is not responsible for any damage to your system/software that may occur.
Messing around in “bash.bashrc” without knowledge
could harm your computer!
– What you choose to do is on you! –