Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I am an a redhat box and I noticed that if I accidentally type in a dir path without cd in front of it, I get a /path/to/dir/: Permission denied.; however, I would expect it to say /path/to/dir/: Command not found. Just as if I typed in nonsense like:

$ sldkfjsd
sldkfjsd: Command not found.

What purpose does this have and what would happen if I was to run a dir as a command as a super user (I don't have sudo access)?

share|improve this question

marked as duplicate by Gilles, uther, warl0ck, jasonwryan, rahmu Feb 21 '13 at 9:39

This question was marked as an exact duplicate of an existing question.

It's a Permission denied because you don't have permissions to execute a directory that way. Usually when you just enter the name of some file on the CLI without anything else, this means you want to execute it. But for directories the execute permissions has a different meaning, thats why you have no Permissions to execute it.

In fact, executing a directory is usually necessary to list its file index, but you can't run it like a binary executable file.

f.e. there is an executable called /bin/ls, so if you enter /bin/ls on the CLI it will call the executable and run it. Now if you try to just enter /bin (the directory) then Bash will do the same and try to call it like an executable, but you don't have permissions to execute it like an executable because its a directory.

share|improve this answer

The same way as if you try to run a PNG image, or anything else that makes no sense to run, that isn't allowed. In the case of files, a file could be made executable by permission bits, as it might contain a program (all commands are in fact regular files that happen to contain machine code and are executable). It will never make sense to run a directory, or a hard disk. Thus no permission.

share|improve this answer

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