Permission Denied in Ubuntu

I've been using Code::Blocks in Windows 7 without any problems. I recently installed Ubuntu 12.10 and downloaded Code::Blocks with GCC compiler. After writing a console application, the program(if there are no errors) builds without any problem. But after i run it, the console window says-Permission denied. I tried changing the directory in which the projects are saved, but in vain. Please help!
Weird. You sure the permissions are set correctly when you do an 'ls -l' command?

You could trying 'sudo'ing it.
I'm new to ubuntu!....Please elaborate!!!!
If you run terminal, navigate the the directory where your application is and type 'ls -l', it should list the contents of the directory with the associated permissions.

If you let me know what the left most column is, I should be able to tell if the permissions are correct.

The column in question should have 10 characters and is usually made up of r, w and x characters.
Last edited on
The project directory is /media/sucho/Edication/Linux-Code::Blocks....i dont have a clue about ubuntu!!!...very sorry for nagging, but i even dont know to navigate directories by terminal! i dont know where code::blocks is installed as i installed it from software centre!!!....wen i run the program the console window says-sh:1: /media/sucho/Edication/Linux-Code::Blocks/Cleanup/bin/Debug/Cleanup:Permission denied (Cleanup is the ptoject name)
Thats all i'm getting right now!!! :-(...Previously a sane kind of problem arose in windows wgen i set the project folder in C:, so instead of changing the security settings i changed the project directory. But this does not help in ubuntu!
are you trying to run the application with a debugger? In other words, are you running the application by pressing "F8"? If so, you are most likely getting a Ptrace error. A way to fix this error is to do:
"sudo echo 0 > /proc/sys/kernel/yama/ptrace_scope" in a terminal.

If this is NOT the case, Code::Blocks could be building a non-executable exe (confusing huh?) This just means that the executable bit isn't set in the file so linux doesn't think it's an executable. To set this bit, you can either right-click the file, go to the "Permissions" tab and check the "is executable" box. OR, you can open a terminal and run "chmod u+x" on the file.

In the off chance the compiler is making a root only file, you can fix that by opening a terminal and go to the build directory using the "cd dir" command (i.e. "cd CodeBlocks") then run sudo chmod 775 on the built exe. (i.e. "sudo chmod 775 MyApp"). After this, make it an executable and run it!
Well Code::Blocks is an IDE. As far as i can see, it's probably a debugger as there is an option-Build Target, which has the option set as Debug. When i Create a project in the IDE, The following thing happens
If the directory is-Cleanup, and the name of the project is 'Cleanup', then
1.a Cleanup.cpd file is formed(It is the code blocks Saved project)
2.Cleanup.depend is formed
3.Cleanup.layout is formed
4.main.cpp is formed(It contains the code)
5.Directory formed-obj/Debug/main.o
6Directory formed-bin/Debug/Cleanup(it's type shows-executable, and this file is the one that is shown-Permission denied)
As you said, In properties->Permissions there was an option-'Allow Executing file as Program' with a check mark in front of it. But the checkmark can't Be ticked. Once ticked, the checkbox automatically becomes blank again!
I tried typing-sudo echo 0 > /proc/sys/kernel/yama/ptrace_scope" in terminal, but the terminal replied-Permission denied! I really Couldn't get the last suggestion.
BTW thanks for helping me around. I feel like a jerk not able to figure it out and continuously nagging you!!
Ok, well......you tried typing "sudo echo 0 > /proc/sys/kernel/yama/ptrace_scope" in a terminal and it replied "Permission Denied"? Did you type your password right?

Also, I'm not entirely sure how to help you, sorry :(
I use Qt Creator and it doesn't have these issues. So it might be worth it to try it out and see if the problem persists. Or, you could try compiling the application manually (without Code::Blocks) and see if that does anything. To do that, you need to navigate to the directory (folder) with the source code in it. Open a terminal in that folder and then use g++ to compile the project.

Assuming you have one file (main.cpp), use "g++ -o MyApp main.cpp"
Then run that file by typing "./MyApp" in the terminal. If you get the same error then we know the issue isn't with Code::Blocks, but instead with Ubuntu. If not, then I would suggest finding a new IDE.

EDIT: I feel it should be noted I use Xubuntu 12.10 64-bit.
Last edited on
Go to the place you have your project and type the following:

sudo chmod 777 project_name

Even better, go to where you have installed codeblocks and type the same command, but this time for security reasons, do this:

sudo chmod 754 code_blocks_Folder


4 = read
2 = write
1 = execute

So when you type 777 for the project_name, you were basically giving permission to the user (you), group (any body with access to that folder), others(any other person), to read, write to and execute the file.

But in your codeblocks folder, you will be giving read, write and execute permission to yourself, read and execute to group and read to others.

http://www.thegeekstuff.com/2010/04/unix-file-and-directory-permissions/
Well thanx guys...my problem is kinda solved! I moved the directory to home folder and then in the the permissions tab under properties of the executable file, i checked on the-Allow executing file as program. No problems now. Though its a little bit irritating to do this every-time when I write a code!
> The project directory is /media/sucho/Edication/Linux-Code::Blocks.
¿what is `sucho'?
I suspect that you are (auto)mounting it with `noexec' option
sucho must be the name of the usb or disk
Topic archived. No new replies allowed.