-1

I know there are many questions like this, but I unfortunately dont know enough about Ubuntu to be able to apply it to my situation. I have all my stuff saved for work on a remote machine, that i access via ssh. I was trying to change something with a conda environment i have there, and changed something in the .bashrc file, and now I cant use vim, or ls - no text editor or command seems to work.

echo $PATH returns: /home/percyrou/bin:/home/percyrou/bin:/home/user/bin:~/ghf_env/bin/

as far as i remember from the .bashrc file before i accidentally changed it, the PATH was just something like : /home/user/bin:

I think all these extra parts got added because i tried to change it with :

echo 'export PATH="/home/percyrou/bin:$PATH"' >> ~/.bashrc (or just with user instead of percyrou, because i wasnt sure which it was), and it seems to add it to the PATH rather than replace it. I did already run source ~/.bashrc

i also tried to use scp to download the .bashrc file to my local machin and edit there, but that also returns bash: scp: command not found, i guess because scp is also contained in my .bashrc file.

Please help! I have no idea how to proceed from here to access my path variable again. :(

3
  • 1
    When your PATH is broken, use full path to executable like /usr/bin/scp instead of scp.
    – mook765
    Commented Jun 23, 2023 at 15:04
  • 1
    You could add /usr/bin to PATH so "scp", "ls", etc can be found. export PATH=/usr/bin:$PATH.
    – Mike
    Commented Jun 23, 2023 at 15:09
  • Your vim is there: /usr/bin/vim
    – Cyrus
    Commented Jun 23, 2023 at 20:11

2 Answers 2

5

You are still able to use scp and other commands, only you need to type the absolute path like /usr/bin/scp instead of just scp (or similarly /usr/bin/ls instead of ls etc.) because the shell cannot find these commands on your $PATH.

Try /usr/bin/cat .bashrc to display the contents of your .bashrc file or /usr/bin/vim .bashrc to edit it. If you can't make the file work properly by editing it, there is a default .bashrc file (that is copied to each user's home directory when creating account) under /etc/skel/.bashrc. Use the following command to copy it over your current .bashrc file:

/usr/bin/cp /etc/skel/.bashrc .bashrc
3
  • Okay this is great thank you !Its still not working yet, but at least with /usr/bin/vim i can at least open it, thanks already so good to know!
    – Learn4life
    Commented Jun 24, 2023 at 10:24
  • Okay I copied over the default, and it still doesnt work. But since my question was mostly about how to access my stuff again, your answer was a success! Thanks so much :)
    – Learn4life
    Commented Jun 24, 2023 at 10:51
  • Did you log in again to a new session after copying the default? It's strange that the default file doesn't work... What is your $PATH after logging in to a new session with default .bashrc file?
    – raj
    Commented Jun 24, 2023 at 11:13
0

Reset your path to a minimum usable version

PATH=$(getconf PATH)

Then fix your .bashrc

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .