6

I rebooted recently, and now terminal fails to work. If I click the terminal shortcut or use Guake or ctrl-alt-T, the terminal opens briefly with no prompt, then immediately closes again. I installed xterm as well and the same thing happens.

If I use ctrl-alt-F1 to get to a command line session and type gnome-terminal I get the error message:

Failed to parse arguments: Cannot open display

How can I diagnose and fix this?

EDIT TO ADD .bashrc

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile"

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
alias zf=/home/julio/ZendFramework-1.12.3/bin/zf.sh

EDIT 2-- adding .profile:

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
    . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

export SCALA_HOME=/usr/share/scala
export PATH=$PATH:$SCALA_HOME/bin
source ~/.profile
Evan Carroll
  • 7,376
  • 15
  • 53
  • 87
user101289
  • 285
  • 1
  • 4
  • 13
  • 1
    Please post the contents of your `$HOME/.bashrc` and `$HOME/.xsession-errors` files. – terdon Mar 10 '14 at 23:36
  • Hmm, that looks fine, could you also post your `$HOME/.profile` if you have it? Also, please try `ctrl-alt-f1` then login, then run `bash`. Do you get any error messages? Do _not_ try running `gnome-terminal` that's a graphical program and will fail with the exact message (`Cannot open display`) in your question, that has nothing to do with your issue. Did you try launching `xterm` or just install it? – terdon Mar 11 '14 at 00:03
  • @terdon-- I ran `bash` and got the message `segmentation fault core dumped` -- I did try running `xterm` and it failed the same way the `gnome-terminal` did. – user101289 Mar 11 '14 at 00:09
  • Can you please run sudo apt-get remove gnome-terminal then sudo apt-get install gnome-terminal and then try again – basketball Mar 10 '14 at 23:46
  • uninstall / reinstall did not fix the issue. – user101289 Mar 11 '14 at 00:08
  • what version of ubuntu are you running? – basketball Mar 11 '14 at 00:13
  • It's Ubuntu 13.04 – user101289 Mar 11 '14 at 00:15
  • ^ @terdon how to do this "Removing the source ~/.profile line from your ~/.profile" ?? – mak2131 Jun 09 '14 at 06:37
  • @mayank well, you open the file `$HOME/.profile` in a text editor and delete the line that says `source ~/.profile` from the file if such a line is there. – terdon Jun 09 '14 at 21:28
  • @terdon i viewed all the files that u have mentioned but none of them have any of those two line. – mak2131 Jun 10 '14 at 05:49
  • @user3667696 yes, well, they're not supposed to. This is just the particular problem that user101289 had. There is no reason to expect your files would have that line since that line breaks your system. If you have a new problem, please post a new question. – terdon Jun 10 '14 at 11:46

2 Answers2

9

This has nothing to do with gnome-terminal, when you hit Ctrl Alt F1, logged in from the virtual console and tried running bash, you got a segmentation fault core dumped which means that bash itself crashes.

Anyway, what's happening is that your bash is entering an infinite loop. When bash first starts, it reads ~/.bashrc (actually, this is a simplification, see here for more details). In your case (and in most if not all Ubuntu versions), the default .bashrc, for reasons that have never been clear to me, sources (reads) ~/.profile as well. Now, your ~/.profile includes this line:

source ~/.profile

The result of that is that bash reads ~/.bashrc => reads ~/.profile => reads ~/.profile => reads ~/.profile => reads ~/.profile etc. This is called an endless loop. Eventually, it freaks out and crashes.

Removing the source ~/.profile line from your ~/.profile should set everything back to normal.

terdon
  • 98,183
  • 15
  • 197
  • 293
  • @terdon-- that sounded like the ticket, but I removed the line, saved the file and rebooted-- same issue. – user101289 Mar 11 '14 at 01:02
  • @user101289 strange. Check the file again, is the line still there? If not, we're going to have to check all of your bash initialization files, post the _full_ contents of each of `~/.bash_profile`, `~/.profile`, `~./bashrc`, `~/bash_login`, `/etc/bash.bashrc` and `/etc/profile`. If any of these don't exist, don't worry about it, that's normal, just post the rest. Feel free to @ ping me in [chat](http://chat.stackexchange.com/rooms/201/ask-ubuntu-general-room). – terdon Mar 11 '14 at 01:06
  • @terndon-- thanks for your help! It appears that there was a similar line saying `#[[ -s "$HOME/.profile" ]] && source "$HOME/.profile"` in `.bashrc`-- I commented that out and I'm back in business! – user101289 Mar 11 '14 at 01:42
0

For mayank

"Removing the source ~/.profile line from your ~/.profile" means just searching for the files ~/.bash_profile, ~/.profile, ~./bashrc, ~/bash_login, /etc/bash.bashrc and /etc/profile (as mentioned in comment), opening them and removing the line:

source ~/.profile

or

#[[ -s "$HOME/.profile" ]] && source "$HOME/.profile     

FYI: '~' is not a strange symbol, it just means your home directory. so its basically the path of .profile file.

Its HOME_DIRECTORY/.profile.