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.

And I didn't find touch in the /bin dir, how can I reinstall "touch"?


/bin/touch is in the coreutils package. You can install this package by running:

yum install coreutils

If yum reports that the package is already installed, then you can run the following commands to reinstall it:

rpm -e --justdb --nodeps coreutils
yum install coreutils

The rpm command removes the rpm database entry for coreutils, which will allow yum to install it again.

vi can be installed from either the vim-minimal or vim-enhanced packages.

  • It works, and all the issues has gone! Really Appreciate! – liuxingruo May 10 '10 at 4:40

At first guess, i'd say your $PATH variable is either empty or broken. Try typing the commands in their entirety, complete with path:

/usr/bin/touch test.txt
/usr/bin/vi test.txt

This is assuming CentOS 5 keeps them in /usr/bin (which I don't have handy to confirm, you can also try /bin)

Also, while you're at it:

/usr/bin/echo $PATH

and make sure /usr/bin (or wherever) is listed in there.

  • bash: /usr/bin/touch: No such file or directory bash: /bin/touch: No such file or directory bash: /usr/bin/echo: No such file or directory – liuxingruo May 8 '10 at 3:38
  • this is my $PATH(root) /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin – liuxingruo May 8 '10 at 4:05

Since it isn't your PATH, it sounds like you can access much of anything.

The first thing I would do is see if your permissions are all messed up for some reason. This of course assumes you can access either stat or ls.

I would also check your /var/log of dmesg to see if you have had a disk error on such a scale that it is not even read-only, or if it is, things have gone really bad.

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.