Solution: “Permission denied” for compiled C programs

Really annoying: sudo, chmod and chown do not help to get those compiled C programs running. In fact Google returns a lot of useless information. Everybody is talking about the wrong usage of IDEs and ubuntu users are wondered if even sudo <compile command> returns “Permission denied”. I want to save my solution for Google. The problem (for me) was the filesystem.

$ vim program.c # write program
$ gcc program.c -o program # compile program
$ ./program # execute program
zsh: permission denied: program
$ sudo cat /etc/fstab
...
UUID=ab47831-ef   /media/fs  ext3  defaults,rw,users  0 0
...
$ sudo vim /etc/fstab
# change line to...
UUID=ab47831-ef   /media/fs  ext3  defaults,rw,users,exec  0 0
$ gcc program.c -o program
$ ./program
zsh: permission denied: program
$ sudo chmod +x program # add executable flag
$ ./program # success :-) 

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>