I'm unable to login through GUI. On typing the correct password, I get a black screen and back to login screen. However, when tried with tty1 I was logged in. Then I tried reinstalling lightdm and xorg packages, but in vain. These are the contents of my xsession-errors

/usr/sbin/lightdm-session: 1: /etc/profile: id: not found
/usr/sbin/lightdm-session: 12: [: Illegal number:
/usr/sbin/lightdm-session: 36: /usr/sbin/lightdm-session: xrdb: not found
/usr/sbin/lightdm-session: 1: /usr/sbin/lightdm-session: ls: not found
/usr/sbin/lightdm-session: 98: exec: gnome-session: not found

How do I overcome this issue?

UPDATE 1: Image of my /etc/profile enter image description here

  • There is no need to add pictures. Add the results as they are in terminal. Copy-paste them here inside code sample. We will need additional info in order to locate the problem. cat /usr/sbin/lightdm-session; cat /etc/lighdm/lightdm.conf; cat /var/log/Xorg.0.log
    – NickTux
    Aug 26 '13 at 12:57

The following lines (taken from /etc/profile on my Debian box) seem to be what you're missing:

if [ "`id -u`" -eq 0 ]; then
export PATH

add them after the first two lines (the comments) and retry your log in.

  • Thanks! This fixed the same problem I had on 13.10, only I had to add /sbin to the user path (else clause).
    – kmarsh
    Dec 23 '13 at 18:01

It sounds like there is a syntax error in your /etc/profile file - probably somewhere around this fragment

if [ "`id -u`" -eq 0 ]; then
  PS1='# '

Likely all the other errors are due to lightdm's environment not being properly set as a result of that (in particular, its PATH variable - so that the executables like 'ls' are not found)

If so, then try opening /etc/profile in the TTY virtual terminal using a command-line editor e.g.

sudo nano /etc/profile

and fixing the syntax

  • steeldriver, I tried to analyze /etc/profile, but could not find out what is wrong. I've added image of my profile file. Please check the update. Thanks. Aug 24 '13 at 18:11
  • OK so it looks like I was wrong - I don't see anything wrong with your /etc/profile. It's possible that the /usr/sbin/lightdm-session script is the problem but that should have been replaced by reinstalling the lightdm package, I think. Sorry - I don't have any more ideas right now. Aug 24 '13 at 19:23

I had the exact same problem, running 13.04. The error message "id: not found" made me think that some change or installation I did somehow does not make the command "id" available. I changed the line if [ "id -u" -eq 0 ]; then to if [ "/usr/bin/id -u" -eq 0 ]; then Using the full path to id solved the problem for me.

  • Welcome to Ask Ubuntu! Where did you the change? Please answer (if you want to help) more verbose.
    – Danatela
    Sep 9 '13 at 15:37

maybe add a line to the top echo $PATH to see if your path variable is being set up correctly. If it is not you may want to add a line export PATH=$PATH:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games <-- that is my default path from ubuntu. This also keeps everything from your original path and adds onto it. It's weird that this would happen though...

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