When I compile my C++ code on my Chromebook's shell, I get the error bash: ./a.out: Permission denied
. This happens even when I run with sudo: sudo: unable to execute ./a.out: Permission denied
. Why does this happen?
1 Answer
The problem ended up being that the filesystem was mounted with the noexec
flag, probably for security reasons. To get around this,
- Run
sudo mount -o remount,rw -o exec PATH/TO/YOUR/FILE
, where PATH/TO/YOUR/FILE is the directory where you're trying to execute the file. - If you get an error like
mount: /home/chronos/user/Downloads not mounted or bad option
, remove the last directory from the command (in this case /Downloads) and try again. Keep removing until it works. - If you get an error like
When remounting eCryptfs, you need to pass the mount utility the -i parameter to avoid calling the mount helper
, runsudo mount -o remount,rw -io exec PATH/TO/YOUR/
.
You should now be able to run the file.