Dan Thomas
Dan Thomas

Reputation: 21

Permission denied, running C++ program bash

I have written and compiled a c program, however I am unable to run it using bash.

I compiled it using the following: g++ -g -Wall -o hello hello.cpp

then tried to run it with: ./hello

which gave me:

bash: ./hello: Permission denied

Upvotes: 1

Views: 3198

Answers (1)

syam
syam

Reputation: 15069

Ensure that the filesystem you're working on is not mounted with the noexec option (which forbids any program to be executed on that filesystem, irrelevant of its executable flag).

An easy way to verify it is to use the mount command and see which mount point corresponds to the directory where you're compiling. If that mount point contains the noexec option, edit your /etc/fstab accordingly and either remount the filesystem or just reboot your system.

Upvotes: 4

Related Questions