Is there a Linux tool for changing DOS/Windows file attributes?

Solution 1:

NTFS-3G includes the setfattr command:

setfattr -h -v 0x00000000 -n system.ntfs_attrib_be target-file

should clear all attributes (the last argument target-file should be changed, of course.) See here for a list of available attributes and how to set them.

Solution 2:

setfattr probably works for NTFS file systems, but in case someone needs to do the same for FAT (vfat/fat16/fat32) file systems, see mtools package. That will do the job!

Solution 3:

If you’re feeling (just like me) setfattr is too low level and error-prone and want something like attrib in Windows or chmod in Linux, then fatattr seems to be the right tool.

Its usage is simple, for example:

fatattr +R FILE  # set FILE read-only
fatattr -H FILE  # set FILE not hidden

To get fatattr on Ubuntu, simply run (with Universe repository enabled):

sudo apt install fatattr