Commands see files, bash doesn’t

Posted on

Problem :

This is a really odd bug I can’t seem to figure it out. Basically, commands like ls can see all the files in the current directory, however when I go to execute the file it will give errors like “file not found”, even when it most obviously is.

alt text

If you look at my command history in the screenshot, you can see I can ls into a directory and see it’s contents. When I try to run the file, I get the “no such file or directory” error.

However, if I type simply ‘vm’, I can’t use tab completion to complete the directory name, and my third command is me typing ‘vm’ and hitting tabtab, it lists a bunch of vmware specific tools instead of the subdirectory name. I can then ls and see my current directory contents, and it will list only the single subdirectory. However, then I tried to use the full filepath from root to run the file, still to no avail. If anyone has any insight, it would be much appreciated.

FYI it’s Ubuntu Server 10.04 inside VMWare Workstation.

Solution :

The fact that the filename is listed in red tells me that it’s likely a broken symlink.

If you do ls -l vmware-tools-distrib/ you’ll probably see something like:

lrwxrwxrwx 1 user group   10 2010-09-10 10:19 -> non-existent-target

When you try to execute a command, bash searches for that command in PATH. The current working directory is usually not included in PATH for security reasons (to avoid Trojan horse attacks). To execute a command in the current directory, precede its name with ./, e.g.,


EDIT: Never mind–didn’t read question carefully.

Leave a Reply

Your email address will not be published. Required fields are marked *