mattrib
Modify MS-DOS filesystem attributes
SYNOPSIS
mattrib [+attribute|-attribute] file1 file2 ...
PARAMETERS
+attribute
Adds the specified attribute flag.
-attribute
Removes the specified attribute flag.
a
Archive bit.
h
Hidden file.
r
Read-only file.
s
System file.
file1 file2 ...
The files to modify.
DESCRIPTION
The mattrib command allows you to modify the extended attribute flags on ext2, ext3, and ext4 filesystems. These flags control various aspects of file behavior, such as whether a file can be appended to, deleted, or modified. It's crucial to understand the implications of changing these flags, as improper use can lead to data loss or system instability. Flags modified using mattrib can be viewed using lsattr and chattr can perform similar functionality to mattrib. mattrib is part of the mtools package, which provides tools for accessing and manipulating MS-DOS filesystems from Linux. The primary use case of mattrib revolves around manipulating attribute flags of FAT/MSDOS files.
CAVEATS
mattrib operates on FAT filesystem attributes. It's crucial to ensure the tool is being used to manage the correct filesystem type. Using it on incompatible filesystems might lead to unexpected behavior or errors.
Changes made by mattrib might not be immediately visible due to caching. Consider unmounting and remounting the filesystem to ensure changes are reflected.
EXIT STATUS
mattrib returns 0 on successful completion. A non-zero exit status indicates an error.
EXAMPLE USAGE
To make a file read-only: mattrib +r myfile.txt
To remove the read-only attribute: mattrib -r myfile.txt
To hide a file: mattrib +h myfile.txt
HISTORY
mattrib is a component of the mtools package, a collection of utilities designed to provide access to MS-DOS filesystems from Unix-like operating systems. The mtools package has been around for a long time, evolving over the years to support various FAT filesystem versions. Its creation was driven by the need for interoperability between Unix and DOS systems, and it continues to be relevant for managing files on removable media formatted with FAT filesystems.