LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   file exists but can not run it. (https://www.linuxquestions.org/questions/linux-newbie-8/file-exists-but-can-not-run-it-508962/)

xface66 12-09-2006 08:42 PM

file exists but can not run it.
 
hello everyone,

i have "authkey" file under /usr/bin
when i type "authkey" command on console it returns me
"bash: /usr/bin/authkey: No such file or directory" error.

this happens for some other files too.
what is wrong here please help me.

indienick 12-09-2006 09:11 PM

You can only run /usr/bin/authkey if its permissions mark it as executable.

Do the following at the command line:
(Remember "$" indicates a user prompt, "#" indicates the super-user prompt)
Code:

$ su
Password: (enter root password)
# chmod a+x /usr/bin/authkey
#

:)

EDIT: Keep in mind, not all files can be executed once their permissions have been changed. Some files are not necessarily programs - it could just be a plain text file, in which case even if you make it executable, you won't be able to run it.

wmakowski 12-09-2006 09:16 PM

This sounds more like a $PATH issue than permission denied. Post the output of echo $PATH. It would also be interesting to see ls /usr/bin/auth*. Is it possible you are running a restricted shell?

Bill

indienick 12-09-2006 10:21 PM

Most programs are installed to /usr/bin, and 99% of the distros out there have /usr/bin in the users' PATH env. variable - so I don't see that being an issue. But it's always worth a shot.

zetabill 12-09-2006 10:57 PM

Quote:

Originally Posted by wmakowski
This sounds more like a $PATH issue than permission denied. Post the output of echo $PATH. It would also be interesting to see ls /usr/bin/auth*. Is it possible you are running a restricted shell?

Bill

I think though, from the "No such file or directory" error, that /usr/bin/authkey were typed at the prompt rather than just authkey. If authkey were typed at the prompt and /usr/bin were not in $PATH or authkey is not in /usr/bin, then the error returned by bash would be "Command not found."

So either the command was typed incorrectly, the file is not executable, or the shell is somehow restricted. I think that authkey probably isn't in /usr/bin.
Code:

which authkey
will tell if authkey is executable from $PATH. If it isn't then find / -name authkey -print as root to see where it is on the system.

xface66 12-10-2006 06:43 AM

i am running in su mode and i have done all u said.
it is on the PATH i know here are the results of your advices.

linux:~ # ls /usr/bin/auth*
/usr/bin/authkey


linux:~ # ls /usr/bin/auth*
/usr/bin/authkey


u see it is on the path but it gives no such file or directory errror

linux:~ # authkey
-bash: /usr/bin/authkey: No such file or directory

where is the problem?

wmakowski 12-10-2006 10:33 AM

I think I know what it might be. Is /usr/bin/authkey a symbolic link? The link could be there, but the actual file it is pointing to is missing. Try ls -al /usr/bin/authkey, and see what you get.
Code:

[root@peanut root]# ls -al /usr/bin/hello
lrwxrwxrwx  1 root root 11 Dec 10 11:20 /usr/bin/hello -> /root/hello

Then follow the link to see if that file is there. In the above case, the link /usr/bin/hello points to /root/hello. When I remove /root/hello and leave the /usr/bin/hello link I get the same message.

[root@peanut root]# hello
-bash: /usr/bin/hello: No such file or directory


Bill

sundialsvcs 12-10-2006 12:27 PM

The which command will search the $PATH to find out which file (if any) will qualify as a command.

Enter: which authkey.

The command will tell you if a qualifying file exists. If not, there is a $PATH issue. If so, there's an execute-permission issue.

Also note (as an aside): if the file you wish to run is in your current directory, Linux/Unix normally does not include that directory in your path. You must prefix it with ".'" to run it. ("." is a reference to "the current directory.") This is done so that you must explicitly (and therefore, presumably, knowingly and intentionally) request to run any program that is "right here," lest someone slip a program into a directory in hope that you will accidentally run it instead of the command you intended to use.


All times are GMT -5. The time now is 06:05 PM.