4.2. Understanding File Attributes

Since the first versions of MS-DOS and the FAT file system (see Book II, Chapter 5), files have had some basic attributes. The following sections deal with only the attributes that a computer user will manage: namely, Read-only, Hidden, System, and Archive. The discussion focuses on the basic attributes, the extended attributes offered by Windows NTFS, and how to change the file attributes.

4.2.1. How attributes are stored

Attributes are stored as a single, 8-bit binary number. Because each bit can hold either a 0 or a 1, this yields 256 possible combinations of attributes — from eight 0s (no attributes applied; equal to 0 in decimal notation) to eight 1s (all attributes applied; equal to 255 in decimal notation).

Because each attribute holds a specific bit position, if several attributes are applied to a file, you can add the values (either binary or decimal) together to get a unique number that is 255 (11111111 in binary) or less for each unique combination of attributes. For example, if the file had the attributes of Read-only (1), System (4), and Archive (32), the value of the attribute byte would be 1 + 4 + 32, or 37. Only 37 (00100101 in binary) could represent a file with these attributes. The full list of attributes is listed in Table 4-9.

Table 4.9. File Attributes
Bit PositionDecimal ValueBinary ValueAttribute
1100000001Read-only
2200000010Hidden
3400000100System
4800001000Volume Label
51600010000Subdirectory
63200100000Archive
76401000000 ...

Get CompTIA A+® Certification All-In-One For Dummies®, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.