【发布时间】:2010-10-15 14:26:17
【问题描述】:
我可以运行具有 000 权限的 Bash 函数并不完全正确,但差不多。我的代码是:
#!/bin/bash
function hello {
echo Hello! }
hello-file 有权限:
-r-------- 1 UnixBasics hello_file
首先,我使用当前权限输入:
$ . ./hello_file;hello
调整是在运行 bash 脚本之前将 400 权限更改为 000:
$ chmod 000 hello_file
$ . ./hello_file;hello [1]
-bash: ./hello_file: Permission denied
Hello!
它给出一个错误,但它不会停止运行该函数。我不明白。我现在取消设置你好功能:“取消设置你好”。我收到错误:
-bash: ./hello_file: Permission denied
-bash: hello: command not found
为什么我第一次没有得到它们?它与缓存、缓冲区或类似的东西有关吗?为什么我可以使用 000 权限 [1] 运行 Bash 脚本?
【问题讨论】:
-
第一行应该是“#!/bin/bash”。
-
非常感谢 Andrew Medico,他对我的文章进行了批判性解读。因此,我在写作中发现了一些令人讨厌的错误,其中似乎存在一些小争论。希望现在一切都是正确的。
-
或者你可以 "mkdir /bash ; cp /bin/bash /bash/bin" :-) 不,不要真的这样做,我只是在开玩笑。
标签: bash file-permissions