Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash commands not found — $PATH damaged [closed]

I accidentally made a mistake when I changed my ~/.bash_profile file and now I'm unable to run any command, such as ls, touch, sudo, etc.

When I write echo $PATH I have this result:

$ echo $PATH
/usr/local/bin:
$

And when I type /bin/cat ~/.bash_profile, I have this result:

export PATH=$HOME/local/node/bin:/usr/local/bin:$PATH
export PATH=/usr/local/bin:$PATHh

But I am unable to change it. Can someone help me, please?

like image 857
Alessandro Avatar asked Sep 01 '13 23:09

Alessandro


People also ask

How do I fix bash command not found?

Sometimes when you try to use a command and Bash displays the "Command not found" error, it might be because the program is not installed on your system. Correct this by installing a software package containing the command.

What does $_ mean in bash?

$_ (dollar underscore) is another special bash parameter and used to reference the absolute file name of the shell or bash script which is being executed as specified in the argument list. This bash parameter is also used to hold the name of mail file while checking emails.

What is $@ in bash?

bash [filename] runs the commands saved in a file. $@ refers to all of a shell script's command-line arguments. $1 , $2 , etc., refer to the first command-line argument, the second command-line argument, etc. Place variables in quotes if the values might have spaces in them.

What is Echo $$ in bash?

The echo command is used to display a line of text that is passed in as an argument. This is a bash command that is mostly used in shell scripts to output status to the screen or to a file.


1 Answers

If you can do /bin/cat, you should be able to /usr/bin/vi, too. Alternately, just fix it in your local shell:

PATH=/bin:/usr/bin:/sbin:/usr/sbin

And then running your favourite editor should work again.

like image 123
Carl Norum Avatar answered Oct 23 '22 13:10

Carl Norum