chmod a=rwx 后 Linux 权限被拒绝
所以我有一个 Linux 的小问题,天哪,这将教会我在 Windows 上度过这么多年。 不管怎样,我做了一个小java应用程序,用Java Service Wrapper脚本很好地包装了,但是当我运行该脚本时:
sh ./wrapper.sh console
我立即得到权限被拒绝。 权限被拒绝的消息是这样的:
eval: 1: /home/user1/MyApp/bin/wrapper: Permission denied
我的小wrapper.sh位于MyApp/bin文件夹中。 目录 MyApp/bin/wrapper 包含 2 个文件:
- wrapper-linux-x86-32wrapper
- -linux-x86-64
作为测试,我运行了以下 chmod 命令:
chmod a=rwx MyApp -R
我验证了所有内容都是 rwx,即使在子文件夹中也是如此,并尝试过再次运行脚本,结果完全相同...权限被拒绝。
有人知道我接下来可以尝试什么来让那个婴儿跑起来吗?
谢谢, 兰斯洛特
So I have a little Linux problem, geez that will teach me to spend so many years on Windows. Anyway I did a little java app, wrapped nicely with the Java Service Wrapper script, but when I run that script:
sh ./wrapper.sh console
I get permission denied right away. The permission denied message is like that:
eval: 1: /home/user1/MyApp/bin/wrapper: Permission denied
My little wrapper.sh lives in the MyApp/bin folder.
The directory MyApp/bin/wrapper contains 2 files:
- wrapper-linux-x86-32
- wrapper-linux-x86-64
As a test I ran the following chmod command:
chmod a=rwx MyApp -R
I verified that everything was rwx, even in the sub-folders and tried to run the script again, with the exact same result... permission denied.
Anyone has any idea of what I could try next to make that baby run?
Thanks,
Lancelot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我刚刚注意到错误消息引用了托管您的文件的目录的名称:
自从您提到“目录 MyApp/bin/wrapper 包含 2 个文件”以来,我们知道它是一个目录。
您能否检查您的脚本,例如使用目录名称作为命令的位置? 例如使用wrapper(这是目录名)而不是wrapper/wrapper-linux-x86-32(这将是文件名),或类似的错误?
当在文件名中使用空格并忘记引用所述文件名时,经常会出现类似的错误(不过,这里可能不是这种情况。)如果
失败,您可以编辑您的问题以包含您正在调用的包装器脚本的内容吗?
(新答案,因为它与之前的 noexec 想法完全无关,可以留下来参考。)
I just noticed the error message references the name of the directory hosting your file:
We know it's a directory since you mentioned "The directory MyApp/bin/wrapper contains 2 files".
Could you check your script for instance where you're using the name of the directory as a command? Such as using wrapper (which is the directory name) instead of wrapper/wrapper-linux-x86-32 (which would be a file name), or similar errors?
Similar errors often appear when using spaces in filenames and forgetting to quote said filenames (probably not the case here, though.)
Failing that, could you edit your question to include the contents of the wrapper script you're calling?
(New answer since it's completely unrelated to the previous noexec idea, and that one can stay for reference.)
托管脚本的文件系统可能会使用
noexec
标志进行挂载。 检查该文件系统的 /etc/fstab 条目,如果有noexec
,请尝试将其删除,然后通过mount /path/to/mountpoint -o remount
重新挂载该文件系统再考虑一下,检查 noexec 实例的 mount 命令的输出而不是 /etc/fstab (文件系统可能已动态挂载。)
The file system hosting your script might be mounted with the
noexec
flag. Check your /etc/fstab entry for that file system and if there's anoexec
there try removing it then remounting that file system viamount /path/to/mountpoint -o remount
On second thought, check the output of the
mount
command for noexec instances instead of /etc/fstab (the file system might have been mounted dynamically.)您可以尝试执行其他用户主目录中的文件,您可以授予用户“user”权限
chmod -R a+x /home/user1
或者
chmod -R o+x /home/user1
chmod -R g+x /home/user1
You may try to execute the file that was there in other user's home directory, you can give permission to the user "user"
chmod -R a+x /home/user1
or
chmod -R o+x /home/user1
chmod -R g+x /home/user1
您可能还必须向您的包装器授予执行脚本
chmod +xwrapper.sh
编辑:我刚刚注意到您的wrapper.sh位于您的MyApp文件夹中
/编辑
另外,如果你确保你
的.sh文件位于顶部,你可以像这样执行它:
.wrapper.sh
you may have to also grant execution script to your wrapper
chmod +x wrapper.sh
EDIT: i just noticed that your wrapper.sh is located in your MyApp folder
/EDIT
also, if u make sure you have
at the top of your .sh file, you can execute it like this:
.wrapper.sh
首先,尝试在文本编辑器中打开它,以确保您具有读取权限。 如果是这样,请执行
并确保脚本开头有
#!/bin/sh
First, try opening it in a text editor, to make sure you have read access. If so, do
And make sure you have
#!/bin/sh
at the beginning of the script虽然我的问题有点不同,但这个问题在我搜索类似问题时出现在我的搜索中几次,所以我将在这里发布我的发现。
我的问题是在 chmod 命令之后我无法访问存储/文件夹。
执行命令后:
我无法再访问存储/文件夹。
我尝试过
ls -l
:也在
git status
之后:执行正确的命令后:
一切恢复正常。
Although my problem was a bit different this question appeared in my search few times while searching for similar problem so I'll post my findings here.
My problem was that I couldn't access storage/ folder after chmod command.
After executing command:
I couldn't access storage/ folder any more.
I've tried
ls -l
:Also after
git status
:After executing the right command:
everything returned back to normal.