Damo
Damo

Reputation: 6433

Permission denied error returned when i was expecting command not found

In a folder that contains the file foo.txt (but any file will do, with any contents). When I run foo.txt i get the error command not found: foo.txt this is expected as its not a command its a file with no execute permissions set.

But if i go into the parent folder and then run myfolder/foo.txt I get the error permission denied: myfolder/foo.txt, why is this? I was expecting the same command not found error.

Many thanks

Upvotes: 2

Views: 2244

Answers (1)

Tomas F
Tomas F

Reputation: 7596

I would guess in the first case it tries to run the command 'foo.txt' from the PATH not from the directory you stand in and thus can't find the foo.txt command in the PATH. If you run ./foo.txt do you get permission denied then?

When running myfolder/foo.txt then it actually tries to run the foo.txt in your folder and does not have executable permission on it.

Upvotes: 1

Related Questions