8

I have Ubuntu 9.4. I've built the program, some basic OpenGL. The program just makes a rotating square. Then run it and:

sh: /blabla permission denied.

And an empty main doesn't work:

int main()
{
    return 0;
}

How can I make that disappear?

jww
  • 97,681
  • 90
  • 411
  • 885
csiz
  • 4,742
  • 9
  • 33
  • 46
  • What are the permissions on the program's file? – Milen A. Radev Jun 17 '09 at 11:08
  • What exactly is the command you are entering? – Svante Jun 17 '09 at 12:06
  • run button in codeblocks, ./test after I do cd ... and double click. None of them work – csiz Jun 17 '09 at 12:31
  • @KdgDev, advising people to make programs world-writable is horrid advice: It means anyone with access to any part of their machine, even the `nobody` user that's supposed to have no access privileges at all, can modify the script to add potentially-malicious content. `750` is more than sufficient for a script one wishes to run oneself, or `755` for world-readability and executability. – Charles Duffy Nov 16 '15 at 17:48
  • 1
    @CharlesDuffy Indeed. Good lord, I left that comment in June 2009. That's over 6 years ago. I think at that point I had maybe once installed Ubuntu via Wubi(fun stuff, Wubi, sad it's not getting maintenance anymore). Having worked with Ubuntu and other distro's in a professional capacity since then, I no longer feel it's funny to say "777 the file" as I did back then. That's like saying "just merge develop in to the hotfix branch, what's the worse that could happen". That actually happened to me once, holy sh*t that gave me cold sweat. – KdgDev Nov 24 '15 at 17:28

9 Answers9

14

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.

Przemyslaw Zych
  • 2,000
  • 1
  • 21
  • 24
7

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

chmod +x myPorgram
./myProgram

something changes?

Paolo Tedesco
  • 55,237
  • 33
  • 144
  • 193
  • I'm compiling with codeblocks. And I tried that nothing, tried with sudo and still nothing. – csiz Jun 17 '09 at 11:22
5

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

Ana Betts
  • 73,868
  • 16
  • 141
  • 209
2

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.

Kenny Cason
  • 12,109
  • 11
  • 47
  • 72
1

Couple of questions:

  1. Are the permissions set correctly on the file?
  2. Is the path to any interpreter set correctly?
Brian Webster
  • 30,033
  • 48
  • 152
  • 225
Rob Wells
  • 36,220
  • 13
  • 81
  • 146
  • I don't know about those things... it only happens on the new computer I had same compilaer same ubuntu and there it just runs – csiz Jun 17 '09 at 11:12
1

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.

Eric Darchis
  • 24,537
  • 4
  • 28
  • 49
  • not a dynamic executable hmmm but in the permission page the executable option is marked and also i did the chmod +x on it... Though I doubt there are extra libraries needed for int main(){} – csiz Jun 17 '09 at 11:33
  • "Not a dynamic executable" ? Can you show us how you are compiling your program ? Please also do a "file yourexefile", this should say something like $ file /bin/bash /bin/bash: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped Regarding the extra libraries, having just main(){} doesn't mean anything, if it was compiled with the opengl libs, they'll be required to run the program. – Eric Darchis Jun 17 '09 at 11:52
  • I'm hitting the build button in codeblocks... that worked on the other computer untill now, I also compiled without any libraries linked and it didn't run. The file test : test: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped – csiz Jun 17 '09 at 12:25
1

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:

Toon Krijthe
  • 52,876
  • 38
  • 145
  • 202
Charl
  • 1
  • 1
0

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

nik
  • 13,254
  • 3
  • 41
  • 57
0

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.

Eric
  • 6,364
  • 1
  • 32
  • 49