Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was updating my .bash_profile, and unfortunetly I made a few updates and now I am getting:

env: bash: No such file or directory
env: bash: No such file or directory
env: bash: No such file or directory
env: bash: No such file or directory
env: bash: No such file or directory
-bash: tar: command not found
-bash: grep: command not found
-bash: cat: command not found
-bash: find: command not found
-bash: dirname: command not found
-bash: / No such file or directory
-bash: preexec_install: command not found
-bash: sed: command not found
-bash: git: command not found

My bash_profile actually pulls in other .sh files (sources them) so I am not exactly sure which modification may have caused this.

Now if I even try and to a list of files, I get:

-bash: ls: command not found
-bash: sed: command not found
-bash: git: command not found

Any tips on how to trace the source of the error, and how to be able to use the terminal for basic things like listing files etc?

share|improve this question
What happens if you use the full path like so: /bin/ls ? And what sorts of changes were you making? – K. P. MacGregor Sep 12 '12 at 2:24
Yes, paste your .bash_profile – January Sep 12 '12 at 2:32
/bin/ls lists the files, but then I see these 2 lines below it: -bash: sed: command not found -bash: git: command not found – Blankman Sep 12 '12 at 2:40
up vote 26 down vote accepted

It looks to me that at one point or another you are overwriting the default PATH variable. The type of errors you have indicates that PATH does not contain /bin, where the above commands (including bash) reside.

For example, you do


instead of

share|improve this answer
I did do this at one point: export PATH=PATH:EC2_HOME/bin – Blankman Sep 12 '12 at 2:45
You have to use '$' in the second PATH string - export PATH=$PATH:EC2_HOME/bin – Manula Waidyanatha Sep 12 '12 at 2:53
strange how 'ec2-describe-regions' doesn't work, even though it is in my path, yet this works: $EC2_HOME/bin/ec2-describe-regions I did a source reload also.... – Blankman Sep 12 '12 at 2:59
doing a echo $PATH, I see it is repeated 3 times: EC2_HOME/bin:EC2_HOME/bin:EC2_HOME/bin how can I fix this, reboot? source'ing it doesn't seem to fix it. – Blankman Sep 12 '12 at 3:02
Look, we don't know what you are doing, what other files you are sourcing, what is in them. And yes, every time you source the file, you append things to your path (which is fine, because normally .bash_profile will get read only once). Go through it one by one and see what happens. Also, isn't EC2_HOME a variable? If yes, then you should precede it with a $ like this: export PATH=$PATH:$EC2_HOME/bin – January Sep 12 '12 at 3:07

One way to begin debugging your bash script would be to start a subshell with the -x option:

$ bash --login -x

This will show you every command, and its arguments, which is executed when starting that shell.

The --login option is specified because .bash_profile is read by login shells. Further information on debugging bash scripts can be found here:

Ultimately, I think that January's suggestion will work for you, but that link is worth a read for future problems.

share|improve this answer

I may have found the problem. It worked for me, and it might work for you...

I was defaulting with my editor to Windows (LF/CR) saves. Since I use both systems, it seemed logical. When I needed to mess with my .bash_profile, I realized after commenting out and tryig things that nothing worked. I changed my saves to OS X format (CR only) and viola! No more "command not found" in the terminal!

It may just be that easy!

share|improve this answer
Very subtle thing that was driving me crazy. Thanks for adding this answer! – samuel.molinski May 7 '14 at 20:51

I have the same problem like you. I can't use many popular command (ls, vi/vim, ..) and can't edit /root/.bashrc when I log in with su into root.

Finally. I found the solution for this problem. Just login root with command:

su -m

After that, you can use

vim /root/.bashrc

to edit PATH.


share|improve this answer

I think I may have found the answer to the problem if not for you then for others who have a similar problem. My answer to this is that I do not have a .bash_profile.

So I was searching all over the web and I found the solution. Which is basically open the terminal, type touch ~/.bash_profile and press Enter. That fixed my problems. Hope it does the same for you

share|improve this answer
LOL... -bash: touch: command not found – Kumar KL May 5 at 7:11

I had exactly the same problem:

If I put in lxterminal:

set | grep "jerom/bash"

if I entered exactly the same command in tty2 I got:

set | grep "jerom/bash"

\r means DOS end of line, so I opened file ~/.bashrc and change the ends of lines in Krusader to unix style. And its working already!!! :-)

The DOS EOLs make spourious problems also in bash scripts.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.