I have an executable on my usb drive. I cd to the directory, ./app yields permission denied. So I did chmod u+x app. Then, ./app. But still, permission denied.!

Then I read something here:

That command [chmod] only changes the permissions associated with the file; it does not change the security controls associated with the entire volume. If it is security controls on the volume that are interfering with execution (for example, a noexec option may be specified for a volume in the Unix fstab file, which says not to allow execute permission for files on the volume), then you can remount the volume with options to allow execution. However, copying the file to a local volume may be a quicker and easier solution.

How would I make a program run off of a USB drive, with or without the above mentioned solution?

  • 1
    If the usb have a fat based file-system, then there is no executable bit to be set. You also have to look at the mount options. Before doing this look at the security risk of running of off a USB (not just this one, but any that could be plugged in). – ctrl-alt-delor May 24 at 19:15
  • mount options - perhaps the mount has noexec. – Jasen May 24 at 20:04
  • if the executable is a "shebang" script you can launch it via the interpreter. – Jasen May 24 at 20:06
  • 1
    And if it's a shared library executable (nowadays "binary" almost always means this), you can run it via the dynamic linker (ld.so, typically invoked as /lib/ld-linux.so.2). – Ferenc Wágner May 25 at 18:22

The command to remount the drive with execute allowed goes like

sudo mount $THING -o remount,exec

but with an apropriate value for $THING. You can use the device name, or the mount point.

  • Will that allow me to read and edit the files on it, too? – user96931 May 24 at 21:53
  • 1
    yes, it may make everything appear to be executable (eg, if it's VFAT format), but fille will continue to be editable and directories writable etc. – Jasen May 25 at 0:21

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.