xsession error: cannot log in after changing environment variable

5,228

Solution 1

You'll probably still be able to log in in text mode. Press Ctrl+Alt+F1 and enter your user name and password at the login: and password: prompts, then run sudo -s to get a root shell. If you have a root password, you can log in as root directly.

The error looks like a failed attempt to set PATH. It's consistent with having an extra space in an assignment, like

export PATH= …$PATH…

instead of export PATH=…$PATH… (or just PATH=…$PATH…).

Depending on the exact nature of the problem, it may be reported at the point where the actual error is or later. To edit /etc/mdm/Xsession, run

nano /etc/mdm/Xsession

If that's not where the error is, check in your dot files and other files in /etc.

grep -s mallet-2.0.7 ~/.* /etc/* /etc/*/Xsession*

Once you think you've fixed the error (feel free to ask a new question on this site if you aren't sure how), press Ctrl+Alt+F7 to return to the GUI login prompt. You can use Ctrl+Alt+F1 and Ctrl+Alt+F7 to switch back and forth between the virtual consoles at any time.

Solution 2

So I also asked for help on the Linux Mint forums and some awesome user solved my problem. Apparently, by using the above command I modified the content of /etc/environment. It should only contain the following:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:"

To change that I had to enter as root in the recovery shell, change the partion to read/write using:

mount -o remount,rw  / 

and than edit /etc/environment using

nano /etc/environment

alternatively you can edit the /etc/environment as root:

sudo nano /etc/environment

Now it works again.

Share:
5,228

Related videos on Youtube

blub123
Author by

blub123

Updated on September 18, 2022

Comments

  • blub123
    blub123 over 1 year

    I tried setting a new environment variable (I use linux mint 17). After restarting, I couldn't log back in. It says:

    Your Session only lasted less thant 10 Seconds. If you have not logged out yourself, this could mean that there is some installation problem or that you may be out of diskspace. Try logging in with on of the failsafe sessions to see if you can fix this problem.

    the ~/.xsession-errors file contains the following:

    /etc/mdm/Xsession: Beginning session setup /etc/mdm/Xsession:: 3: export: :/home/myusername/mallet-2.0.7/:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin: bad variable name

    so I basically tried to change the environment variable, trashed something in the process and can't log in. How can I repair this without logging in, while keeping all the data on my computer?

    The command I used for changing the environment variable was

    sudo gedit /etc/environment
    echo "export PATH=$PATH:/home/myusername/mallet-2.0.7/" >> ~/.bashrc
    

    Any help would be greatly appreciated!

    • jsbillings
      jsbillings almost 9 years
      echo "export PATH=$PATH:/home/myusername/mallet-2.0.7/" >> ~/.bashrc So, that's going to interpolate the existing value for $PATH into your .bashrc, and not the string '$PATH'. Probably not what you intended.
    • jsbillings
      jsbillings almost 9 years
      Also, the error you are getting makes me think you used: export $PATH=$PATH..., because it's claiming that you're using ":/home/myusername/mallet-2.0.7/:/usr/lib/jvm/java-8-oracle/‌​bin:/usr/lib/jvm/jav‌​a-8-oracle/db/bin:/u‌​sr/lib/jvm/java-8-or‌​acle/jre/bin" as a variable name.
  • gloomy.penguin
    gloomy.penguin almost 9 years
    your second sentence just saved my life. seriously. i was going to go get a drink. thanks.......! i've only worked off linux servers, this is my first at home laptop. i don't know anything all over again.