LinuxCommandLibrary

mattrib

Modify MS-DOS filesystem attributes

SYNOPSIS

mattrib [+/-a] [+/-h] [+/-r] [+/-s] [-X] [-/] [-D drive:] [files...]

PARAMETERS

+a / -a
    Sets (+) or clears (-) the archive attribute. The archive attribute is typically used by backup programs.

+h / -h
    Sets (+) or clears (-) the hidden attribute. Hidden files are not normally shown in directory listings.

+r / -r
    Sets (+) or clears (-) the read-only attribute. Read-only files cannot be modified or deleted without first clearing this attribute.

+s / -s
    Sets (+) or clears (-) the system attribute. System files are essential operating system files, often hidden and read-only.

-X
    Operates on extended attributes, which might be specific to certain mtools configurations or when dealing with Linux-specific extended attributes mapped to DOS attributes on VFAT.

-D drive:
    Specifies the MS-DOS drive letter to operate on (e.g., A:, C:). This mapping is typically defined in the mtools.conf file.

-/
    Processes subdirectories recursively, applying the attribute changes to files within subdirectories as well.

DESCRIPTION

mattrib is a utility from the mtools package designed to modify the MS-DOS file attributes of files and directories on FAT (File Allocation Table) filesystems. These attributes include archive, hidden, read-only, and system flags. It allows Linux users to control properties commonly found in DOS and Windows environments, making it essential for managing files on floppy disks, USB drives, or disk images formatted with FAT, without needing to boot into a DOS/Windows environment.

When invoked without attribute modification options, mattrib displays the current attributes of the specified files. It functions similarly to the ATTRIB command in MS-DOS.

CAVEATS

mattrib exclusively operates on MS-DOS compatible filesystems (like FAT/VFAT). It does not interact with native Linux file permissions or extended attributes (such as those managed by chattr). Its functionality depends on the correct configuration of the mtools suite, particularly the mapping of drive letters to actual devices or directories in /etc/mtools.conf or ~/.mtools.conf.

ATTRIBUTE DISPLAY

When no +attribute or -attribute options are provided, mattrib will display the current attributes of the specified files. For example, mattrib filename.txt would show 'A R H S' if those attributes are set.

WILDCARD SUPPORT

Like most Linux commands, mattrib supports standard shell wildcards (e.g., *, ?) for specifying multiple files to modify their attributes simultaneously.

HISTORY

mattrib is a component of the mtools software package, which was developed to bridge the gap between Unix-like operating systems and MS-DOS filesystems. Its inception was crucial for facilitating data exchange and manipulation of files on floppy disks and other DOS-formatted media directly from a Unix environment, without the overhead of mounting or specific kernel drivers. The mtools suite has been a staple in Linux/Unix distributions for decades, maintaining compatibility with legacy DOS file structures.

SEE ALSO

mcopy(1), mdir(1), mformat(1), mtools(1), chattr(1), attrib (DOS/Windows)

Copied to clipboard