Linuxstar
Published on

mattrib command-change or display the attributes of MS-DOS files

Jonas

Jonas

1 min read

The mattrib command is used to change or display the attributes of MS-DOS files. MS-DOS files refer to a collection of related information recorded on storage media (such as disks and CDs).

mattrib is the mtools tool command, which simulates the attrib command of MS-DOS and can change the attributes of MS-DOS files.

Syntax: mattrib [parameter] [file]

Command parameters
-a/+aRemove/set backup attributes
-h/+h  Remove/set hidden attributes
-r/+r Remove/set read-only attribute
-s/+s Remove/set system properties
-/ Recursively process files containing all subdirectories
-X Output results in a shorter format
Example

List the attributes of all files on the MSDOS format disk in slot A:

[root@linuxstar ~]# mattrib a: 

Remove the hidden attribute of the msdos.sys file on the A-slot disk:

[root@linuxstar ~]# mattrib -ha:msdos.sys 

Increase the read-only attribute of the msdos.sys file on the A-slot disk:

[root@linuxstar ~]# mattrib +ra:msdos.sys

Remove the backup and system attributes of the msdos.sys file on the A-slot disk:

[root@linuxstar ~]# mattrib -a -sa:msdos.sys

Remove the read-only attribute of all files in the sub-directories contained on the A-slot disk:

[root@linuxstar ~]# mattrib -r -/ a:*.*