How to Edit Path in Bashrc

How to Edit Path in Bashrc

I edit PATH and just insted $PATH i write SPATH sooo I'm stock in login loop

and with root terminal try to login and edit PATH

so, I don't know how to get bashrc with which command and how to edit PATH

3

3 Answers

You may know a few of these details, but I'm hoping to provide a list that will help you get through this.

  1. .bashrc is found in a user's home directory.
    • /home/usera/.bashrc
    • /root/.bashrc
  2. $PATH should be export'd for persistence and sub-shells.
  3. You will likely only ADD to $PATH, and be careful not to reset it completely.
    • BAD export PATH="/less/important/path:/lesser/important/path"
    • GOOD export PATH="${PATH}:/less/important/path:/lesser/important/path"
  4. The system will use the first found match, starting with directories on the left or beginning of the $PATH list.

If you find yourself with a really messed up configuration file, take a look at /etc/skel, and either copy that over, or use it as a reference for this and other configuration files provided to new users.

For editing path and saving it permanentaly, u can use vi editors for that.

  1. Go to your home directory:

    cd ~

  2. type this command:

    sudo gedit ~/.bashrc

this will ask you for root password, as you want to set the path.

  1. make a variable HOME = /home/user/data -> as your home to access the information. and use this variable like:

    PATH = ${HOME}/path_to_the_desired_application

before exiting the bashrc file, save the modified changes... This should work and you can edit your path in bashrc file.

Open root terminal(may be in recovery mode chosen at boot) and edit .bashrc with following command: replace "youruser" with actual user name

nano /home/youruser/.bashrc

Fix a typo and try to login as that user.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.