chmod a=rwx 后 Linux 权限被拒绝

发布于 2024-07-16 08:28:20 字数 630 浏览 9 评论 0原文

所以我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

胡大本事 2024-07-23 08:28:20

我刚刚注意到错误消息引用了托管您的文件的目录的名称:

eval: 1: /home/user1/MyApp/bin/wrapper: Permission denied

自从您提到“目录 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:

eval: 1: /home/user1/MyApp/bin/wrapper: Permission denied

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.)

风蛊 2024-07-23 08:28:20

托管脚本的文件系统可能会使用 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 a noexec there try removing it then remounting that file system via mount /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.)

请远离我 2024-07-23 08:28:20

您可以尝试执行其他用户主目录中的文件,您可以授予用户“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

抱猫软卧 2024-07-23 08:28:20

您可能还必须向您的包装器授予执行脚本

chmod +xwrapper.sh

编辑:我刚刚注意到您的wrapper.sh位于您的MyApp文件夹中
/编辑

另外,如果你确保你

#!/bin/sh

的.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

#!/bin/sh

at the top of your .sh file, you can execute it like this:

.wrapper.sh

微凉徒眸意 2024-07-23 08:28:20

首先,尝试在文本编辑器中打开它,以确保您具有读取权限。 如果是这样,请执行

chmod +x wrapper.sh

并确保脚本开头有 #!/bin/sh

First, try opening it in a text editor, to make sure you have read access. If so, do

chmod +x wrapper.sh

And make sure you have #!/bin/sh at the beginning of the script

記憶穿過時間隧道 2024-07-23 08:28:20

虽然我的问题有点不同,但这个问题在我搜索类似问题时出现在我的搜索中几次,所以我将在这里发布我的发现。

我的问题是在 chmod 命令之后我无法访问存储/文件夹。

执行命令后:

sudo chmod -755 storage -R    //notice -755 is wrong, it should be 755

我无法再访问存储/文件夹。

我尝试过 ls -l

存储权限 d---------

也在 git status 之后:

storage/.gitignore: 权限被拒绝

执行正确的命令后:

sudo chmod 755 storage -R // without -

一切恢复正常。

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:

sudo chmod -755 storage -R    //notice -755 is wrong, it should be 755

I couldn't access storage/ folder any more.

I've tried ls -l:

storage permissions d---------

Also after git status:

storage/.gitignore: Permission denied

After executing the right command:

sudo chmod 755 storage -R // without -

everything returned back to normal.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文