This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes c on ubuntu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "c on ubuntu " Watch "c on ubuntu " New topic

c on ubuntu

amit nagarkoti

Joined: Jan 31, 2011
Posts: 3

i've been trying on c code on ubuntu using gcc , the program compiles , but when i run it using ./a.out or ./myfile it always ends up with the error permission denied .
i don't know how to get rid of it i've tried remounting the parttion in executable form but it didn't helped either , im using ubuntu 10.10 .
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46430
Never had that problem. Tryand see whether the files have execution permission (x). Try . . . but whenever I have used gcc, the output files have automatically had execute permission.
If that fails, try again in a directory you have "ownership" of.
amit nagarkoti

Joined: Jan 31, 2011
Posts: 3

when i moved the current files to home directory everthing worked fine but on the previous location the error remains same

scylla@scylla-Inspiron-N5010 /media/softwares/learning/c $ chmod a+x *
scylla@scylla-Inspiron-N5010 /media/softwares/learning/c $ ls -l
total 41
-rw------- 1 scylla scylla 7155 2011-03-17 13:10 a.out
-rw------- 1 scylla scylla 7257 2011-03-14 21:31 cc
-rw------- 1 scylla scylla 90 2011-03-14 21:30 copychar.c
-rw------- 1 scylla scylla 7155 2011-03-14 12:06 hel
-rw------- 1 scylla scylla 7091 2011-03-14 07:52 hello
-rw------- 1 scylla scylla 74 2011-03-17 13:10 hello.c
-rw------- 1 scylla scylla 7091 2011-03-14 19:20 new
scylla@scylla-Inspiron-N5010 /media/softwares/learning/c $ ./a.out
bash: ./a.out: Permission denied

anyways im able to run it now atleast on adifferent location and thanks for the reply
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17423

Well, the "execute" bit wasn't set on a.out, even when you forced it. It's possible that the media was mounted with the "-r" (readonly) option ???

There are a few even more subtle reasons why the "x" bit might now be honored (like umask), but that's more than I normally deal with myself.

An IDE is no substitute for an Intelligent Developer.
Adam Koblentz

Joined: Mar 18, 2011
Posts: 19

You're doing this on a location mounted through the "media" mount point. There's an excellent chance your usual account doesn't have permissions to do that. Generally, ubuntu is very strict about mount points. Try sudo and see if that works. Maybe tweak your permissions.
I agree. Here's the link:
subject: c on ubuntu
It's not a secret anymore!