Saturday, May 4, 2024
7
rated 0 times [  7] [ 0]  / answers: 1 / hits: 36042  / 3 Years ago, fri, september 17, 2021, 1:41:48

I've closed the terminal killing a process, after that when opening a new terminal the prompt wasn't there.



After searching online other questions, with CTRL-C y get the prompt back.
However, when opening a new terminal the prompt is gone again.



I've tried the following code:



^Cmartin@martin-N550JV:~$ 
martin@martin-N550JV:~$ ps
PID TTY TIME CMD
17626 pts/0 00:00:02 bash
20957 pts/0 00:00:00 ps
martin@martin-N550JV:~$ sudo kill 20957
[sudo] password for martin:
martin@martin-N550JV:~$ sudo kill 17626
martin@martin-N550JV:~$


Taken from this site



I've also uninstalled and then re-installed the terminal, with no success.



Is there a solution for this?


More From » command-line

 Answers
4

When you open a terminal you get a non-login, interactive shell. If you are using bash the system-wide per-interactive-shell startup file is /etc/bash.bashrc and user-level per-interactive-shell startup file is ~/.bashrc.



The problem you are facing may be due to presence of any bad instruction(s) in any of these two files.



From OP's reply:




sourcing ~/.bashrc initiate the problem. That means there is problem with ~/.bashrc




Possible reasons of disappearing bash prompt:



There might be recursive sourcing that can create an infinite loop type situation. For example if there are lines present in your ~/.bashrc like,



if [ -f ~/.profile ]; then
. ~/.profile
fi


It will source ~/.profile. But keep in mind that ~/.profile always sources ~/.bashrc (it is correct way). Hence you are in an infinite loop. Do not source ~/.profile from ~/.bashrc



Under such situation you can not get the prompt unless you hit Ctrl+C



Troubleshooting



You can put a line in your ~/.bashrc



set -x


Then you could see that the file descriptor is stopping when you open a terminal.



How to recover



Take backup of ~/.bashrc and get a new one from /etc/skel. Use in terminal,



mv ~/.bashrc ~/bashrc.bkp
cp /etc/skel/.bashrc ~/


It will replace your ~/.bashrc with a new one.



Either the problem is like as I expected (described above) or something else should be solved after replacing ~/.bashrc as it is solely related to your ~/.bashrc.


[#26767] Friday, September 17, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hical

Total Points: 498
Total Questions: 106
Total Answers: 117

Location: Comoros
Member since Tue, Mar 14, 2023
1 Year ago
;