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?
14 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.cppHere 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.cppIf 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