I occurred a really weired problem, which is touch : command not found.

I was going to create a blank file, so I type the touch command which didn't work.

I'm running centOS 5.

Any ideas?

BTW: the vi command also not found.

  • 3
    Type echo $PATH, what do you see? Or try "/bin/echo $PATH"
    – Stephen
    May 8, 2010 at 2:56

5 Answers 5


You probably temporarily messed up your path. It may be enough to do:

exec /bin/bash

Then you can try touch, etc. to make sure things are normal.

If that doesn't work, the PATH definition is wrong in one of your system files.


Try to find the command manually. It will be a file named touch and on my current system it is /bin/touch. You can find it by with locate touch or even find / -name touch. If you find it with locate and it isn't where it says that it should be, that could mean that it was recently moved or deleted.

Once you find the command, make sure that it is in your PATH with echo $PATH. If all this works, try specifying the path and command together (i.e. /bin/touch foo). You may also want to check your aliases to see if there is anything there messing things up.

As an observation, you mention that vi isn't working either. In my system, both vi and touch are in /bin and not /usr/bin. Check to see if you are able to run other commands from there.


I made the mistake of overriding my PATH in a script;

while read -r PATH; do
  touch "${PATH}";
done < <(git diff-tree --no-commit-id --name-only -r "${COMMIT_ID}")

The read -r PATH bit cleared the path to the touch binary.

Fix was a simple rename:

while read -r GIT_PATH; do
  • In general you should choose lowercase (or at least not-all-uppercase) names. If GIT_PATH was an environment variable (e.g. exported in /etc/profile) that matters for some tool you're going to use, then the tool could misbehave. With git_path you should be safer from such mishaps because sane tools use uppercase names for variables. Not entirely safe though, e.g. zsh uses path along with PATH. Picking a safe name takes some knowledge of your environment and your shell. Oct 22, 2021 at 14:36

Try the following command:

type touch

It may tell you that the touch command is at /usr/bin/touch and if so:

/usr/bin/touch ...
  • it tells me: "-bash: type: touch: not found"
    – Anonymous
    May 8, 2010 at 3:08

You might have unintentionally deleted touch

You can reinstall by copying it from another computer to:


using command: sudo cp path/to/copied/touch /bin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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