Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have installed GCC compiler using

Install the build-essential command. after the installation I wrote a simple c prgm. I tried to run with following command:

gcc First.c
./a.out

but I'm getting " bash: ./a.out: Permission denied " message. I don't know what to do now.

share|improve this question
add comment

3 Answers

Looks like the executable file a.out doesn't have the execute (+x) mode set.

Run the command chmod a+x a.out to give the user the right to run the file. After that you can execute the file by running ./a.out in a terminal.

There's another way to achieve the same thing:

1) Right-click the a.out file in the file browser.

2) Select Properties from the drop-down menu

3) Open up the Permissions tab

4) Check the box Allow to execute this file as a program.

share|improve this answer
add comment

Execute the command

ls -l a.out

This will show the permissions granted to the file like below.

-rw-r--r-- 1 js js 0 2011-03-27 19:45 a.out

The first set is permissions and to execute it as such you need permission 'execute' Grant the execute permission using chmod +x a.out or chmod 755 a.out

share|improve this answer
    
sh ./a.out is not going to work. This is a binary, not a shell script. –  Adam Byrtek Mar 27 '11 at 15:29
    
Thanks.. for correction Adam –  Jamess Mar 27 '11 at 15:38
add comment

give that program (I mean a.out) the permission to "be executed" by this command:

chmod +x ./a.out

then execute it ;-)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.