在 Linux 上运行我自己的程序的权限被拒绝?

发布于 2024-07-23 23:48:57 字数 1552 浏览 10 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(9

伪心 2024-07-30 23:48:57

我遇到了同样的问题,看来我的分区被安装为 noexec
cat /etc/mtab

当我在 /etc/fstab 中配置选项时,我编写了 exec,user 但似乎“user”选项默认设置为“noexec”。 当我将这两个命令更改为 user,exec 时,一切都恢复正常!

希望能帮助到你。

I had the same problem and it appeared that my partition was mounted as noexec
cat /etc/mtab

When I configured options in /etc/fstab I wrote exec,user but it appears that "user" option by default sets up "noexec". When I changed the order of these two to user,exec everything went back to normal!

Hope it helps.

薄情伤 2024-07-30 23:48:57

你如何编译它? 你能发布makefile吗? 如果你运行

chmod +x myPorgram
./myProgram

一些改变?

How are you compiling it? Can you post the makefile? If you run

chmod +x myPorgram
./myProgram

something changes?

2024-07-30 23:48:57

通过运行“mount”检查挂载点以查看其是否挂载为 noexec

Check the mountpoint to see if it's mounted as noexec by running "mount"

演出会有结束 2024-07-30 23:48:57

我在 Ubuntu 上使用 CodeBlocks,并且多次遇到过这个问题。
KermiDT所说的正是解决方案(如果我有足够的代表点,我会投票赞成)
“user”选项默认设置“noexec”。
所以在 /etc/fstab 中只需在 user 之后添加 ,exec 即可。
即我的看起来像这样:
/dev/sda6 /media/DATA vfat uid=kenny,gid=kenny,users,user,exec 0 0
虽然间距有点小……但你明白了。

I use CodeBlocks on Ubuntu and have had this exact problem MANY times.
what KermiDT said is exactly the solution (if i had enough rep points, i would have voted it up)
The "user" option by default sets up "noexec".
so in /etc/fstab just add ,exec after user.
i.e. mine looks like this:
/dev/sda6 /media/DATA vfat uid=kenny,gid=kenny,users,user,exec 0 0
Though, the spacingis a bit off... but you get the idea.

李不 2024-07-30 23:48:57

除了上面提到的 chmod +x 文件之外,另一个问题可能是缺少库。 要检查所需的库,请使用 ldd:

$ ldd /bin/sh
    linux-vdso.so.1 =>  (0x00007fffb43fe000)
    libc.so.6 => /lib/libc.so.6 (0x00007fc4abe11000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fc4ac183000)

如果其中一行显示缺少库,您就会知道在运行程序之前需要安装什么。

另一种可能性是您的程序是脚本(shell、perl、python 或其他基于文本的程序)。 第一行如下所示:

#!/usr/bin/perl

如果找不到该文件,您将收到权限被拒绝的错误。

Apart from the above mentioned chmod +x file, another problem might be a missing library. To check the required libraries, use ldd:

$ ldd /bin/sh
    linux-vdso.so.1 =>  (0x00007fffb43fe000)
    libc.so.6 => /lib/libc.so.6 (0x00007fc4abe11000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fc4ac183000)

If one of these lines shows a missing library, you'll know what needs to be installed before you can run your program.

Another possibility is if your program is a script (shell, perl, python or other text-based program). The first line looks like:

#!/usr/bin/perl

If that file cannot be found, you'll get a permission denied error.

泪痕残 2024-07-30 23:48:57

有几个问题:

  1. 文件的权限设置是否正确?
  2. 任何解释器的路径是否设置正确?

Couple of questions:

  1. Are the permissions set correctly on the file?
  2. Is the path to any interpreter set correctly?
怎会甘心 2024-07-30 23:48:57

尝试在 64 位系统上执行 32 位应用程序时也会遇到此问题。 执行:

a. file (executable name)
b. uname -a

并检查两者都是“i386”或“amd64”。

如果它们不相同,请查看 这篇文章

You also get this problem when trying to execute 32-bit apps on a 64-bit system. Execute:

a. file (executable name)
b. uname -a

and check that both are either "i386" or "amd64".

If they are not the same, have a look at this article:

人│生佛魔见 2024-07-30 23:48:57

尝试使用 strace 执行命令来跟踪成功的系统调用它的发出和停止的位置。

这就是您启动它的方式,

strace ./blabla

您是否收到“权限被拒绝”错误或类似“执行格式错误”之类的错误? 在文件上使用chmod +rx,您不应点击“权限被拒绝”。

Try executing the command with strace to trace the successful system calls it makes and where it stops.

This is how you might launch it,

strace ./blabla

Do you get a "permission denied" error or something like "exec format error"? With chmod +rx on the file you should not hit "permission denied".

寄居者 2024-07-30 23:48:57

您还应该确保您的用户名位于视频组中。 检查 /etc/group 并确保您的用户名出现在“视频”行上。

You should also make sure that your username is in the video group. Check the /etc/group and make sure that your username appears on the "video" line.

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