can't execute c++ binaries, "permission denied"... even though permission is 777
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
can't execute c++ binaries, "permission denied"... even though permission is 777
i'm having trouble executing simple c++ binaries. bash returns a permission denied error, even though i set the file's permissions to 777. i'm using g++ compiler on RH9. for some reason it works on my laptop, also RH9. does it have something to do with installed c++ libraries? any suggestions on how to fix it?
I think we would need a little more info than you have provided to determine what is going wrong..
Can you paste the command you entered, the error output and anything else that might help us determine what's going on.
It is possible that your binary is attempting to load a shared object for which you dont have read permissions..
If you are not getting much info on what is going bad, you can do an strace on your binary to see if it is something like that.
Code:
strace -e trace=file <your_executable>
This will allow you to see all system calls to file routines and see if it is your binary accessing something or not, also you will see what it failed to open.
Who ownes the directory where the executable will end up? Perhaps it needs 777 also. And if you are trying to execute from the current directory, is it in the path. BF
Is your filesystem mounted with the noexec option? "grep -i exec /etc/fstab" or "mount|grep -i exec". Have you configured any of the Access control systems. (I don't know what Redhat includes).
Can you run a shell script (or simple c program) from this directory. It may not be related to c++ at all.
hey good suggestions chris. the drive where i am running these binaries is separate from my linux installation drive, so that seemed like a pretty good explanation. unfortunately, that wasn't it. here's the entry for the drive where it's running from:
i've never heard of any "access control systems" in redhat. is this a gui configurator in debian?
i tried copying the cat binary to the directory that i'm trying to run the c++ binaries from. here's the input/output:
$./cat hello.cc
bash: ./cat: Permission denied
it's funny that perl scripts run from this drive. i think we're on to something. i copied the c++ binary to my other drive and it worked. so what else would keep binaries from running on a mounted filesystem?
This option implies the options noexec, nosuid, and nodev (unless overridden by subsequent options, as in the option line user,exec,dev,suid). Quothe the mount man page on the user option. Makes sense, I guess.
I am new in ubuntu with two years of GNU experience. GNU systems like linux are marvelous and you, the community too. Thanks for your help. The solution and the process to diagnosticate the problem help me too. Thanks. Adding "Mount" option "exec" is the key... eh ;-)
$more /etc/fstab | grep exec
/dev/hda9 /home/user/docs ext3 defaults,user,exec 0 2
I am new to ubuntu. was writing a cpp program in vi editor(i suppose d editor is not dat important though), but as i put the command for output, it said permission denied... i tried out crtain things that i am pasting here.. even that didnot work.. I have no ida whatsoever
Note the when running the program, the .cpp extension is not used.
P.S. The -o option instructs the GCC (g++) linker what to name the executable program. Change the name to something else if you wish. If you do not specify the -o option, the executable program will be named a.out.
thanks for the post... it worked!
wel i had compiled it earlier and then executed ofcourse. wel couldnot understand 1 little part in dis... i had tried ./a.out as well. and if -o is not utilized, ./a.out should give the result, which didnot occur so.. can you please explain me this?
thanks anyway, it worked.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.