Technical blogs are always to the point. So for my daily blog viewers this must be new. But this is how technical blogs goes. I divide it into four sections:
- Technology Overview
- Problem Encountered
- Proposed Solution of a Tested Fix
- Related Posts
So Let’s learn to troubleshoot this issue which I faced while trying to tweak the .bashrc file from terminal.
Technology Overview
.bashrc File: Whenever Bash is run interactively the .bashrc script is run. This file is a place where all commands we enter in terminal are executed. It binds those commands and paths of the commands. Mostly the aliases are stored for execution. Also for users to execute any commands from their terminal can add the aliases in .bashrc file.
Problem Encountered
You might have messed up with your .bashrc file in performing your own tweaks. In my case I messed with the file by adding a PATH variable for Laravel. I added the script in the bottom of file. Saved the file. Than we need to compile the file using source command. I did source ~/.bashrc in terminal. Than something got screwed. Terminal now doesn’t execute any command. Type ls, dir,whoami, cd nothing works. So yours case might also be similar.
How to fix it then?
Solution
There are blogs which instructs us to restore the .bashrc.old file and perform a restart. This is how it is done:
cd [your-home-directory] mv .bashrc .bashrc.old cp /etc/skel/.bashrc . sudo reboot
But that solution works if messing up with .bashrc file caused some other issues like, unable to see the desktop and running other commands. In my case the terminal commands were not working. So I used virtual terminal.
- To enable Virtual Terminal press Ctrl _ Alt + F1 keys
- Perform login with your system username and password
- Now, first undo all your changes in .bashrc file.
- Do nano ~/.bashrc and either delete the changes or just comment it by adding # in front of the line
- Save the changes and get out of that file. Ctrl + X and Yes(Y)
- Now compile the file with command source ~/.bashrc
- Reboot your system.
This will compile the changes and you will get back your terminal commands in your interactive terminal. This worked for me. I am using Ubuntu 16.04 currently. This will work on any distribution version of Ubuntu.