Question

This might be a noob question, but I need help. I screwed up my terminal by trying to alter my path variable using the following command:

$ sudo nano .profile

Before I did that, if I were to type: $ echo $PATH

I would get: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

When I opened .profile in nano it told me that the file didn't exist. I figured that made sense, since I had never edited this file before. I proceeded to enter a path to a directory I was using for a php framework and saved the file.

After I saved the file, I noticed that none of my bash commands are working. Now I can't do anything from the terminal. I can't even edit .profile in nano because it says -bash: nano: command not found

I'm clearly new to working with the terminal. I feel completely lost. Please provide some guidance on how to restore the terminal to working condition.

Was it helpful?

Solution

Use absolute paths.

 $  /usr/bin/sudo /usr/bin/nano .profile

If you add something to a path, never just do

 PATH=/path/to/something

instead do

 PATH=$PATH:/path/to/something

By the way, you shouldn't/don't have to use sudo to edit your own file, such as .profile. Use sudo only when you need to edit the file which doesn't to belong to your account.

OTHER TIPS

I had the same problem! The way I solved was writing the follow command in the terminal: PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/usr/local/git/bin:/usr/X11/bin

Hope it can be useful for you

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top