1

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?

1
  • 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, 2012 at 23:22

3 Answers 3

2

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.

2
  • ls is installed.
    – Wombats
    Jan 28, 2012 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
    – runejuhl
    Jan 28, 2012 at 22:00
1

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?

0

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.

1
  • It still shows the path.
    – Wombats
    Jan 28, 2012 at 21:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .