How to mark "allow executing file as program" on an external drive
If I try to set this option for a file on an external drive it just unmarks itself. Doing chmod +x
has no effect. The drive is mounted with default options.
Solution 1:
Your external disk is likely formatted NTFS or FAT32. Those filesystems do no support Linux file permissions.
You've now at least five options:
- Just copy it to the desktop (or your Home folder) and set the permissions on that file.
- Backup the data on it and reformat the drive to the
ext4
filesystem. This can be done using the Disk Utility or GParted - Execute the file with a program, open a terminal and run:
- for Bash scripts:
bash /path/to/your/file.sh
- for Python scripts:
python /path/to/your/file.py
- for Perl scripts:
perl /path/to/your/file.pl
- for windows executables:
wine /path/to/your/file.exe
- for 32-bit binaries:
/lib/ld-linux.so.2 /path/to/your/file
- for 64-bit binaries:
/lib/ld-linux-x86-64.so.2 /path/to/your/file
- for Bash scripts:
- Copy the file to your computer (e.g. home folder), set the execute bit on it and run it. (this cannot be done for all files)
-
(possibly dangerous) Mount the partition with the execute bit set for all files. To do so, follow these instructions:
- Mount the partition (by opening it in a file browser for example)
-
Open a terminal and run:
sudo mount -o remount,fmask=027 /media/YOURDRIVE
If you cannot write / access files, run the command with
,uid=$(id -u)
afterfmask=022
:sudo mount -o remount,fmask=027,id=$(id -u) /media/YOURDRIVE
"Possibly dangerous" because you grant execute permissions to all files, only use this option if the other methods do not work.
Solution 2:
If the filesystem is formatted as FAT or NTFS, you could always mount it with appropriate permissions. The default permissions when you mount from command line include execution permissions for all users.
To obtain more specific results, see the manual pages of mount.ntfs-3g
and mount
, the latter in the section Mount options for fat, in particular take a look at options uid
, gid
, umask
, fmask
, dmask
,