bash: ./a.out: Permission denied
On 10/19/2011 06:08 PM, Joe Zeff wrote:
> On 10/19/2011 09:50 AM, shailesh wrote:
>> when i try to run compiled c program ("./a.out") get error
>> bash: ./a.out: Permission denied
>
> Files aren't automatically executable under Linux.
>
> chmod u+x a.out
> ./a.out
>
> will get you what you want.
gcc (well, strictly speaking it's ld but called by gcc) normally gives
executable output files exec permissions when compiling regardless of umask:
$ umask 0002; echo -ne '#include <stdio.h>
int main(int argc, char
**argv)
{
printf("%s
", "Hello World!");
}' > x.c; strace -f gcc
x.c 2>&1 | grep chmod
[pid 11229] chmod("a.out", 0775) = 0
Getting EACCESS on a freshly compiled binary often implies that the file
system doesn't allow executable permissions - either it's mounted with
noexec, SELinux is preventing the exec or the file system does not
support executable permissions.
Are you using removable/network storage? What's does mount say?
Regards,
Bryn.
--
users mailing list
users@lists.fedoraproject.org
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
|