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?
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.
stat -c '%A %n' /bin/ls
tell you? It should be something like this: -rwxr-xr-x /bin/ls
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?
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.
ls
is a binary so a faultyPATH
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?