Can't login to Ubuntu 17.04 after editing environment variables for java

I installed Java jdk and updated my etc/environment to

PATH="/use/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
JAVA_HOME="opt/java/jdk-10.0.1"
export JAVA_HOME
export PATH="$PATH:$JAVA_HOME/bin"

And today when I rebooted , I couldn't login and I'm stuck in a login loop.

When I enter into the shell I couldn't execute ls because it said /bin is not included in the PATH environment variable. I added the following line to the end to the end of ~/.bashrc

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

Now when I login into the shell it gives the same error but I can ls, nano, etc. in the following commands.

I sense that the login loop is also due to this error. Also I added the following line to the top of /etc/bash_completion

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

but it didn't solve the problem.

Answers 1

  • During the process of your changes, you have run the elevated command sudo in your personal space whereas you have lost permission to some of the files needed for your GUI environment.

    You can verify this with this command:

    $ sudo chown -R $(whoami):$(whoami) ~/
    

    You can resolve it by giving owner to the problem files with:

    $ sudo chown -R $(whoami):$(whoami) ~/
    

    You may also have to verify the integrity of your login manager after taking charge via the commands avaible. You can do this with lightdm with these two commands:

    $ sudo apt install --reinstall lightdm 
    $ sudo dpkg-reconfigure lightdm
    

    As per the chat, errors resulting from the latter commands are due to trying to work with a broken repository... running an EOL version of Ubuntu. This can be resolved by upgrading or downgrading to a supported version. Choices are:

    • 14.04 LTS (downgrade)
    • 16.04 LTS (downgrade)
    • 17.10 (upgrade)
    • 18.04 LTS (upgrade)

Related Questions