The main reason I want this is my heavy use of dircolors, especially for ls --color=auto. For example, whenever a .mp3 file is copied from NTFS, it will have permissions set by umask 022 which ought to be standard value in most modern distros. However, for audio files this makes no sense: due to the fact that their permissions get set to 755 (rwxr-xr-x), they will get the same color as an executable shell script, while I'd really like to have this color reserved for true executables. This is not Windows; even with the x permission set for owner/group/other you cannot expect ./track1.mp3 to work in terminal so that it make an attempt to pick a default console player.

So I'd like to have a certain umask ONLY for audio files, i. e. that any files like .mp3, .wav, .ogg and so on would always get set their mode to 644, while leaving all other files copied to this place at their default umask of 022.

Is there any way to accomplish this?
(NOTE: cp --preserve will NOT preserve original permissions on NTFS either, since NTFS is notoriously ignorant about *NIX permission systematic.)

2 Answers 2


You could use a script for your own user-defined cp command that checks file extensions and uses chmod appropriately...

You could do something simple like: (using install rather than cp chmod as per @fd0. That's smarter anyway.)


unset args[${#args[@]}-1]

if [ ! -d "$dest" ]; then
    echo "Please specify a destination directory as the final argument."
    exit 1

for file in "${args[@]}"; do
    if [ "$file" == *".mp3" ] || [ "$file" == *".wav" ] || [ "$file" == *".ogg" ];  then
        install -m644 "$file" "$dest"
        install -m755 "$file" "$dest"

exit 0
  • Yeah, it would be nice to have a built-in solution since this type of behavior would make a lot of people happy but I think you may be stuck with a home-grown solution. Commented Mar 23, 2015 at 18:14
  • "since this type of behavior would make a lot of people happy" - You can say that again. It's no real fun always having to remove silly permission flags that do not belong there for audio files (e. g. executable in a standalone way). Commented Mar 23, 2015 at 18:15
  • All in all this is a nice approach, thank you. I think I can inject some more tricks into my script later myself, e. g. checking out the FROM file system whether it is NTFS, e. g. result=$(lsblk -no FSTYPE) and then test the $result value whether it reads "ntfs". Caveat: Some big HDDs might consist of partitions with both ext and NTFS file systems on them, so make sure your arguments for lsblk are partitions, not devices. Commented Mar 23, 2015 at 18:18

I would use the install tool to copy from NTFS.

install -m644 file1 ... fileN destination_directory
  • This is fantastic! First time I've heard of this handy little program. Thank you so much, your answer is about to get my "accepted answer" vote, unless...wait and see. Commented Mar 23, 2015 at 18:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .