5

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?

5
  • Does the prompt disappear again if you type source ~/.bashrc? Feb 28, 2014 at 1:36
  • I've typed it, but I don't see a result.
    – marbel
    Feb 28, 2014 at 2:23
  • @MartínBel plz tell me if you run source ~/.bashrc your prompt is going away or not? it will not solve your issue it is just a troubleshooting step.
    – sourav c.
    Mar 2, 2014 at 2:59
  • @souravc The prompt goes away.
    – marbel
    Mar 2, 2014 at 4:41
  • Which terminal are you using? Have you tried xterm or xfce4-terminal?
    – landroni
    Mar 2, 2014 at 6:57

4 Answers 4

6
+100

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.

3
  • 1
    Plz let know if your problem still persists.
    – sourav c.
    Mar 2, 2014 at 5:50
  • This worked just fine! Thanks for the help! I'll give you the points when the site allows me, in 8 hours.
    – marbel
    Mar 2, 2014 at 15:57
  • set -x was the ticket to figuring out what command failed. Thanks!
    – blakev
    Jul 3, 2020 at 6:22
3

Running this command has solved this problem for me:

reset
0

I was having the issue of non-running, locked lxterminal and a mere $ for the xterm prompt.

I found on my old N600C running Lubuntu 14.04 updated to 16.04, that echo $0 told me I was running /bin/sh instead of /bin/bash.

After that it was just an issue of changing the default shell to /bin/bash in the way that I saw fit for my installation. There are several ways to do that; they're outside the scope of the OP problem, though.

When I changed back to /bin/bash, it fixed xterm as well as lxterminal, now both show user, host, and pwd.

0

Likely, the shell prompt has been accidentally customized to be blank.

In a terminal window, do:

sudo cp /etc/bashrc /etc/bashrc.sav
sudo nano /etc/bashrc

Then change PS1 to become:

PS1="[\u@\h:\w ] $ "

Save, and exit.

The folowing command will show the bashrc files - what do you have?

ls -al /etc/ba* 
4
  • This is what I get:^Cmartin@martin-N550JV:~$ martin@martin-N550JV:~$ sudo cp /etc/bashrc /etc/bashrc.sav [sudo] password for martin: cp: cannot stat ‘/etc/bashrc’: No such file or directory
    – marbel
    Feb 28, 2014 at 0:50
  • See last two lines above.
    – K7AAY
    Feb 28, 2014 at 1:20
  • First two linesmartin@martin-N550JV:~$ ls -al /etc/ba* -rw-r--r-- 1 root root 2177 mar 30 2013 /etc/bash.bashrc -rw-r--r-- 1 root root 45 jun 17 2012 /etc/bash_completion
    – marbel
    Feb 28, 2014 at 2:24
  • It seems the folder bashrc isn't there. martin@martin-N550JV:/$ cd /etc martin@martin-N550JV:/etc$ cd bashrc bash: cd: bashrc: No such file or directory martin@martin-N550JV:/etc$
    – marbel
    Feb 28, 2014 at 5:16

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.