2

I'm using Ubuntu 13.10. Whenever I login on the command line (tty1-tty6) I get the following output:

Last login: ...
Welcome to Ubuntu 13.10 ...

Unable to connect to X server
Unable to connect to X server

And then the regular prompt. I'm wondering if there is a way to track down what is causing the "Unable to connect to X server" message. What processes/files run when I login this way?

1

You can ignore those messages if you like. They're attempts by your shell to establish connections to your X (Unity) desktop.

Debugging

If you're really driven to debug these you can try enabling debug messages in your login configuration files. Try adding set +x to your .bashrc and .bash_profile files, or which ever configuration files your environment is using. You can disable it like this, set -x.

I'll often wrap these around blocks of commands that I want to see more verbose output from.

Example

In my .bashrc file.

...
set +x
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi
set -x
...

Now when I log into the system.

...
New release '13.04' available.
Run 'do-release-upgrade' to upgrade to it.

You have mail.
Last login: Tue Jan 21 19:15:05 2014 from greeneggs.bubba.net
++ alias 'll=ls -alF'
++ alias 'la=ls -A'
++ alias 'l=ls -CF'
++ alias 'alert=notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
++ '[' -f /home/manny/.bash_aliases ']'
++ shopt -oq posix
++ '[' -f /usr/share/bash-completion/bash_completion ']'
++ . /usr/share/bash-completion/bash_completion
+++ [[ himxBH == *v* ]]
+++ BASH_COMPLETION_ORIGINAL_V_VALUE=+v
+++ [[ -n '' ]]
+++ set +v
...
  • This worked, but I eventually just used some echo statements to track down a call I was making to xinput in my .zshrc file. Thanks! – Pan Thomakos Jan 22 '14 at 2:18
1

There definitely are ways to track this down. First off, you could use strace on an "su -" command; that might do the trick. Or, perhaps an strace of a simple "bash -il" might work.

strace -f -o su.trace su - $(whoami)
strace -f -o bash.trace bash -il

Try one (I recommend the bash one first) and see if it reproduces the output. Note the "-o" option redirects the traced output to a file. If you're not familiar with strace, the output can be a bit much to filter through.

Secondly, placing debug statements in RC scripts (like .bashrc) could be used to track them down.

  • This worked, but it was definitely harder to track down the statement using strace. Thanks for the reply! – Pan Thomakos Jan 22 '14 at 2:18

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.