0

I have added one line in bashrc and after that terminal is not working as expected, no path is showing and I am unable to run any command: Below line i have added in bashrc:

. ~/.profile

enter image description here

3 Answers 3

3

The line you added tells ~/.bashrc to source ~/.profile. However, Ubuntu's default ~/.profile is set up to source ~/.bashrc. So you just set up an infinite loop: ~/.bashrc is sourcing ~/.profile which is sourcing ~/.bashrc which is sourcing ~/.profile and so on, for ever. Since ~/.bashrc is read every time you open a new terminal, it enters this infinite loop, never exits and therefore leaves you with the problem you see.

Since you can log in graphically, just use a GUI editor to remove the line, as others suggested, and you will be OK.

0

Edit .bashrc using a GUI editor, geany for example, and remove the line you added. There must be some GUI editor installed by default in Ubuntu.

4
  • I tried i opened /etc/bash.bashrc but this file seems different. and the line is not in this file Jul 2, 2020 at 13:40
  • Apparently you edited ~/.bashrc. It's the user's bashrc, not the global /etc/bash.bashrc. Try to edit this file.
    – Krackout
    Jul 2, 2020 at 13:42
  • 2
    @KumarHarsh please don't edit /etc/bash.bashrc. Open the file browser and press Ctrl+H to show hidden files. You should see .bashrc right there in your home directory. Click to open with Gedit or whatever text editor wants to open it and remove that line you added.
    – Zanna
    Jul 2, 2020 at 13:43
  • Thanks @Zanna it is in home directory. Jul 2, 2020 at 13:45
-3

New start (I really have not the ability of multitask). Boot in recovery-mode

mv /home/your-user-name/.bashrc home/your-user-name/.bashrc.bak 

afterwards cp the default file

cp /etc/skel/.bashrc  /home/your-user-name/.bashrc

Then you have to change ownership of that new file.

chown your-user-name:your-user-name /home/your-user-name/.bashrc

reboot.

5
  • He couldn't do that, he wasn't able to type any commands, no prompt :)
    – Krackout
    Jul 2, 2020 at 13:50
  • okay, it is better to rename the broken $HOME/.bashrc.
    – nobody
    Jul 2, 2020 at 14:06
  • Yes, renaming would be better, but the main issue is that the OP can't run any commands because their shell never finishes initializing since they have set it to go into an infinite loop. So no command can be a solution, unless you also explain how to log in as a different user or using a different shell so commands can be executed again.
    – terdon
    Jul 2, 2020 at 14:08
  • You don't need to change the ownership, you copied it as your user so it will be created with the right permissions. But in any case: the OP can't do any of these things if you don't also explain how they can get around the fact that they currently can't open a terminal and run any commands.
    – terdon
    Jul 2, 2020 at 16:51
  • In recovery-mode?
    – nobody
    Jul 2, 2020 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.