0

I've compiled a C++ program using the Sublime Text build system, but on a different computer it says "Permission denied.".

Option to execute as a program is marked, I think I set the permissions to 755 too.

Is there anything that I need to do? Do I need to install gcc to run programs?

Edit: I was using the file from my pendrive (FAT32), that could be the problem maybe. But if I need to set permissions I'd move the the file to the Desktop.

Kenny
  • 177
  • 1
  • 1
  • 8

1 Answers1

1

I was using the file from my pendrive (FAT32), that could be the problem maybe.

Almost definitely. We have questions on executing on FAT-based filesystems dating right back to the start of Ask Ubuntu.

Simply put, that's probably your problem if you're using the default mount options and the best fix is to switch to a better filesystem. Ext4, even NTFS... Just something mildly POSIX compliant that supports execute bits. Or you can hack around it and manually mount all the files as 755 (eugh).

You can sidestep the permissions framework by executing the file with the ld linker system. It's a bit messy but it should work for a binary file (probably won't work on scripts):

/lib64/ld-linux-x86-64.so.2 /path/to/64bit-binary
/lib/ld-linux.so.2 /path/to/32bit-binary

If it's a script you can also load a file through its interpreter's binary (rather than relying on a shebang):

sh /path/to/script.sh
python /path/to/script.py
Oli
  • 293,335
  • I was using a 32-bit system, I really thought I didn't. Also, do I need gcc to run programs or it can run compiled programs on stock? – Kenny Feb 06 '15 at 13:07
  • 2
    It's a filesystem issue —the ld workaround is just a cool/scary workaround—. Fix the problem by using a proper filesystem. Copy the file off to a filesystem that supports execution. – Oli Feb 06 '15 at 13:11