Glam Prestige Journal

Bright entertainment trends with youth appeal.

I installed Code Blocks from Software Center. I wrote a C++ program and built it and it was fine, but whenever I try to run the compiled code it gives me this error: Permission denied. How can I fix this problem?

1

4 Answers

You need the execute permission to run/execute the file. If the file is /home/user/test.cpp and you are the owner of the file then to execute the file you need the permission bits like:

-rwxr--r-- 1 user user 1490 Feb 13 12:07 /home/user/test.cpp

Here only the owner ('user' in this example) can read, write and execute the file whereas the group ('user' in this case) and all others can only read the file.

To set the permission like this run the following command from Terminal:

sudo chmod 744 /home/user/test.cpp

If you do so, the execute bit will be set and you will now be able to execute the file.

Check permission for that particular c++ file that you have created.ls.If permission is not there,then use chmod.

Problem can be your Drive where c++ file is saved. The problem occurs in FAT32. Format and change the drive to ext4 and then run the program.

Another issue can be g++. Install g++ by using the command below.

sudo apt install g++
0

Try running this command into the terminal:

chmod 755 filename.extension

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy