简体   繁体   中英

In ubuntu: I can not change files and get “file can not be found” even though the file exists?

When I change a bash script (Ubuntu 10.04), the script gets changed, but when I run it it runs an older version and the changes made are ignored. And some files, it just says that the file does not exist (even though it does...)

I assume it has something to do with permissions, even though I have made sure the files are marked Read&Write for all users and executable. But it is perhaps a permission I need to change on a 'higher level'? Desperate

I changed permissions for the folder and then restarted the computer. Then it worked (but had to restart which I think is a bit odd). Anyway now it works :)

If you want to know which version of a file will be run on Linux/Unix, you can usually type:

which prog

where "prog" is the name of the program. For example, if you want to know where "emacs" is located, or which copy of emacs you are actually using, you can type:

which emacs

On my machine, this returns with:

/usr/bin/emacs

In your case, if the path returned by "which" doesn't match the name of the file you are editing, then this would explain your confusion, and point you in the right direction to solving the problem. I would also examine the contents of your PATH environment variable by typing:

echo $PATH

If you see the other directory in the path before the directory with the file you are editing, this explains the problem. Also, note that "." (the current directory) is never on the path, or at least should never be on the path, for security reasons. If you want to run a program in the current directory, use the form "./prog" explicitly to ensure that it runs the program "prog" in the current directory.

From what you tell me this has nothing to do with permissions.

Double, triple, quadruple check in both your editor and in your terminal you are editing and executing the same files. This has brought me quite a few WTF moments.

The exact commands you enter in your terminal would help though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM