LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   PATH set incorrectly and lost bash: vi command... how can I change .bashrc? (https://www.linuxquestions.org/questions/linux-newbie-8/path-set-incorrectly-and-lost-bash-vi-command-how-can-i-change-bashrc-757033/)

Lindz 09-22-2009 12:27 PM

PATH set incorrectly and lost bash: vi command... how can I change .bashrc?
 
Hi im new to linux. Im trying to install a software and wrote the PATH in the .bashrc file. However, I followed someone elses hand written example (taken from their computer elsewhere) however they left out the $PATH command, for example:

PATH=/pathdestination/
export PATH

Since then I have lost all my bash commands, ls, vi, su, sudo etc. when I type in echo $PATH I get:

/pathdestination/ (from the above example) but that is it.

I can go to the directory containing the .bashrc file however I can't open it to view using 'vi bashrc' I just get:

bash:vi:command not found

When I try to access using root 'su' or 'su -' I also get

bash:su:command not found

So I'm stuck as to how to modify the .bashrc file. Could someone please help me?

Thanks in advance :)

Lindsay

mobinskariya 09-22-2009 12:31 PM

just delete the newly added line from .bashrc and relogin.

Lindz 09-22-2009 12:40 PM

Hi,

I would only but i cant open the .bashrc file to delete it cos the command 'vi .bashrc' doesnt work. I just get:

bash:vi:command not found

Im new to all this so is there another access to that file that can let me do that. 'pico' and 'joe' dont work cos iv already tried those as well (just incase)

mobinskariya 09-22-2009 12:45 PM

so you are in cli.. then give the absolute path to vi command
Code:

/usr/bin/vi .bashrc

j_jerry 09-22-2009 12:47 PM

Its because vi is no installed. Install vi or open in another editor. Also remember to include entire path to the file; like vi /home/YOU/.bashrc

Lindz 09-22-2009 12:48 PM

Thank you very much :)

vi was installed as I had used it all afternoon. Just completely lost everything with two lines of incorrect code! Scary linux!

mobinskariya 09-22-2009 12:50 PM

which reply did you find helpful??

edit:@j_jerry i assumed that vi is installed and the problem was due to $PATH

j_jerry 09-22-2009 12:55 PM

@mobinskariya

Quote:

Originally Posted by Lindz (Post 3693141)
Thank you very much :)

vi was installed as I had used it all afternoon. Just completely lost everything with two lines of incorrect code! Scary linux!

he made it clear; but i wonder how he got command not found

mobinskariya 09-22-2009 12:57 PM

because his $PATH was altered..

@Lindz in future if you want to add a new path to your $PATH do as following
Code:

$PATH=/your/path:$PATH
/your/path is searched first for your command and then rest.
Code:

$PATH=$PATH:/your/path
now you know what above code means.

regards
mobin

Lindz 09-23-2009 03:00 AM

I knew vi was already installed so i was saying thanks for how to open vi by using the full path '/usr/bin/vi .bashrc' ( I am so new I didnt even no that!) I already knew what to write for the $PATH only I copied someones else who wrote it quickly not thinking and then it went pear shaped!

However, I do actually think there may be a bigger problem. Iv come back into work and reset my linux entering as myself and the root but the screen has gone from the red hat desktop with tool bars etc to a pale blue screen with only a command prompted and a clock in the top corner. Its dual booted so im working on my windows version for the time being hoping this will ring a bell to anyone?

Lindz 09-23-2009 05:01 AM

Managed to solve it by putting in the first disc of the red hat CD and carrying out a rescue. It was the only way it would let me open up the file as even writing the full location of 'vi' would not work.

Thanks again

Lindsay :)


All times are GMT -5. The time now is 01:25 PM.