File permissions change when transfering between external drives and laptop

I noticed a few years ago that when I transfer files back and forth between my laptop and my external drive all the files that I have transfered have changed permissions.

I format all my external drives as exFAT so I can use larger files.

Why does this happen?

Is there a better way to keep the file permissions intact when transfering files back and forth between external drives?

The test file: Fantastic Fungi (2019).mkv

+++++++++++++++++++++++++++++++++++++++++++++++++++

This is what the file permssions looks like before I transfer it to my external hard drive

ls -l

-rw-r–r-- 1 user user 577761580 May 2 2024 ‘Fantastic Fungi (2019).mkv’

+++++++++++++++++++++++++++++++++++++++++++++++++++

This is what the file permssions looks like after I transfer it back to my laptop

ls -l

-rwxr-xr-x 1 user user 577761580 May 2 2024 ‘Fantastic Fungi (2019).mkv’

When I right click file permissions dialogue box. The “Allow this file to run as a program” is ticked.

+++++++++++++++++++++++++++++++++++++++++++++++++++

The way have overcome this is to run a simple one liner to reset the permissions for directories and files.

Open a terminal in the directory of the folders and files you want to change

All directories will be 775. All files will be 664

find . -type d -exec chmod 0755 {} ;

find . -type f -exec chmod 0644 {} ;

Directory permission 0755 is similar to “drwxr-xr-x”

File permission 0644 is equal to “-rw-r–-r–-“.

-type d = directories

-type f = files

+++++++++++++++++++++++++++++++++++++++++++++++++++

  • nyan@sh.itjust.works
    link
    fedilink
    arrow-up
    2
    ·
    3 hours ago

    exFAT is a Microsoft creation that (unsurprisingly) doesn’t understand or preserve Linux-style file permissions. Neither did any of the FAT varieties before it. So the permissions on the files when you get them back relate to the mount options you pass to the exFAT drive (in this case, you probably want to set dmask and fmask), or the permissions on the directory it’s mounted to.

    If you don’t want to twiddle with mount options, you could reformat the external disks using Linux-native filesystems like ext4, but you’ll lose the ability to mount them on Windows if you do that.

    • infjarchninja@lemmy.mlOP
      link
      fedilink
      arrow-up
      1
      ·
      2 hours ago

      Thank you nyan

      I will look into the dmask and fmask mount options.

      Definitely a no! in regards to attaching my drives to any windows machine.

      The last windows machine I turned on was a Windows 95 machine when they first came out.

      I thank god, That I wouldnt even know how to turn on a windows 10 or 11 surveillance machine.

    • N0x0n@lemmy.ml
      link
      fedilink
      arrow-up
      1
      ·
      3 hours ago

      but you’ll lose the ability to mount them on Windows if you do that.

      One viable solution to that, is to mount that drive as SMB share, best of the two worlds !