permission denied running my own program (ubuntu)

2019-04-23 17:27发布

问题:

Not exactly programming related...

I've built the program, some basic opengl, then run it and sh: /blabla permission denied. How can I make that dissaper?

the program just makes a rotating square and I have ubuntu 9.4

just found out that even int main(){} doesn't work

回答1:

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.



回答2:

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

chmod +x myPorgram
./myProgram

something changes?



回答3:

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



回答4:

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.



回答5:

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.



回答6:

Couple of questions:

  1. Are the permissions set correctly on the file?
  2. Is the path to any interpreter set correctly?


回答7:

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:



回答8:

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



回答9:

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.