How to Change File Attributes in MS-DOS 6.22
In MS-DOS 6.22, the primary utility used to view and modify file
permissions and flags is the ATTRIB command
(ATTRIB.EXE). Because the FAT file system used by DOS lacks
the complex access control lists (ACLs) found in modern operating
systems, file permissions are managed entirely through four specific
file flags: Read-Only, Hidden, System, and Archive. This article
outlines the function of the ATTRIB command, defines each
attribute, and demonstrates the syntax required to manage files
effectively in MS-DOS.
The Four File Attributes in MS-DOS
MS-DOS 6.22 relies on four standard 1-bit flags assigned to each file or directory:
- Read-Only (R): Prevents a file from being altered, overwritten, or deleted by standard DOS commands.
- Archive (A): Marks files that have been created or modified. Backup utilities (such as MSBACKUP) use this flag to determine which files need to be archived, clearing the flag once backed up.
- System (S): Identifies critical operating system
files (such as
IO.SYSandMSDOS.SYS). System files are typically excluded from standard directory listings and protected from accidental deletion. - Hidden (H): Prevents files from displaying during a
standard
DIRcommand unless specific switches (likeDIR /A:H) are used.
Basic Syntax
The general syntax for the ATTRIB command is:
ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] [drive:][path][filename] [/S]
+(Plus sign): Sets (enables) an attribute.-(Minus sign): Clears (disables) an attribute./S: Applies the command to matching files in the current directory and all of its subdirectories.
Common Usage Examples
1. Viewing File Attributes
To display the flags currently assigned to files in the working
directory, run ATTRIB without attribute switches:
ATTRIB *.*
The output displays columns showing letters (R,
A, S, H) corresponding to active
flags beside each filename.
2. Protecting a File (Read-Only)
To prevent accidental modification or deletion of a critical configuration file:
ATTRIB +R CONFIG.SYS
To remove the read-only restriction later:
ATTRIB -R CONFIG.SYS
3. Hiding and Unhiding Files
To hide a sensitive file from standard directory listings:
ATTRIB +H DATA.TXT
To make the file visible again:
ATTRIB -H DATA.TXT
4. Managing System Files
To remove both the Hidden and System attributes from a file simultaneously:
ATTRIB -S -H IO.SYS
5. Modifying Files Recursively
To set the Archive attribute on all text files across the current folder and all subdirectories:
ATTRIB +A *.TXT /S