Path Error In Environment File In Linux

There are many reasons for looping the login screen. But this case differs from others because of the PATH Which holds all the commands for our computer in their $path. If we do something wrong that causes us to loop the login screen. It wonā€™t allow us to login into your computer.

Before logout from our computer, if we change the $path in the environment file, like if we removed the old PATH and added a new PATH (we accidentally removed  ā€œ/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/binā€ from ubuntu)

    /bin/
           Which holds commands like ls, cat, cp, etc.. (for single-user mode).

   /sbin/
          Which holds commands like init, ip, mount, etc.

  /usr/bin/
             Which holds commands that are executed by users which are not needed for booting the system. Which are not installed locally should be placed here.
 

These are some of the file locations, like these, we add more file locations to execute commands.




 

Save your path like this and restart your environment file to apply changes.
If we did something wrong in our path like saving the file in the below picture


 

If we restart our file using a source command like below
              source /etc/environment

Now the environment file is updated and commands are not going to be executed.
 

To get all commands to be executed like previously we need to reset the path in the environment file.
Firstly set a temporary path so we can use commands in that terminal, once you close your terminal your path will be disabled.

            export PATH=ā€/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/binā€

Now open your environment file
             sudo nano /etc/environment
Now set your path like this




Now save file and update file using source.
             source /etc/environment
If we don’t do this and restart or shut down your pc, it will go through a continuous loop and never allow you to login to your pc.

Solution for your continuous loop is:

Press ctrl+alt+f3 in your login screen which takes to your terminal, to login to your pc terminal




After login set a temporary path so we can use commands in that terminal as i said before

      export PATH=ā€/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/binā€

Now open your environment file
            sudo nano /etc/environment

Now after saving the file, update the file using source.
              source /etc/environment

Now come out of terminal using

                   ctrl+Alt+f1 or ctrl+Fn+Alt+f1
                                    (or)
                   ctrl+Alt+f2 or ctrl+Fn+Alt+f2

It varies based on pcā€™s
It returns to the login screen, and you can login to your pc as usual.

Leave A Comment

Your email address will not be published. Required fields are marked *