All commands have been working until a few days ago on our Ubuntu server. When running ls or cd it returns bash: /bin/ls: No such file or directory.

How can this be fixed?

link|improve this question
ls is a binary so a faulty PATH environment could be to blame as many folks have suggested. However, cd is also a shell builtin, which should be working. Does it report exactly the same error? – Kyle Smith Jan 28 at 23:22
feedback

3 Answers

It seems like the ls executable is missing. ls is part of the coreutils package on Debian-based systems, so you might want to see if it's been uninstalled.

You can use aptitude:

runejuhl@lapaz:~$ aptitude search ^coreutils$
i coreutils                      - GNU core utilities

In the above, the "i" in the beginning of the line means that the package is indeed installed.

link|improve this answer
ls is installed. – Wombats Jan 28 at 21:28
Hmm. What does stat -c '%A %n' /bin/ls tell you? It should be something like this: -rwxr-xr-x /bin/ls – Rune Jacobsen Jan 28 at 22:00
feedback

Surprisingly, the same message would be generated in this situation: /bin/ls binary is replaced with a shell script, but this shell script has an invalid bang line (for example if it starts with #!/this/does/not/exist). Hmmm, rootkit?

link|improve this answer
feedback

Check your /etc/environment file to make sure it still specifies the path. The default Ubuntu (as of 9.10) has just one line in it:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"

That one line gets pulled into various sub-systems that handle login however. Setting the PATH elsewhere can mess Ubuntu's GDM up.

link|improve this answer
It still shows the path. – Wombats Jan 28 at 21:09
feedback

Your Answer

 
or
required, but never shown

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