What Is The Attrib Command

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

What Is the Attrib Command?

The attrib command is a Recovery Console command used to change the file
attributesfor a file or directory while in Recovery Console.
An attrib command is also available from the Command Prompt.

Attrib Command Syntax


attrib [+r|-r] [+s|-s] [+h|-h] [+c|-c] [filename]
+r = This assigns the read-only file attribute to the file or directory.
-r = This removes the read-only attribute.
+s = This assigns the system file attribute to the file or directory.
-s = This removes the system attribute.
+h = This assigns the hidden file attribute to the file or directory.
-h = This removes the hidden attribute.
+c = This assigns the compressed fileattribute to the file or directory.
-c = This removes the compressed attribute.
filename = This is the file or directory that you are wanting to change the attributes of.

Attrib Command Examples


attrib +r c:\windows\system\secretfolder
In the above example, the attrib command is used to turn on the read only attribute,
using the +r option, for the secretfolder directory located in c:\windows\system.
attrib -h c:\config.sys
In this example, the config.sys file located in the root directory of the c: drive has its
hidden file attribute cleared by use of the -h option.

Attrib Command Availability


The attrib command is available from within the Recovery Console in Windows 2000
and Windows XP.

Attrib Related Commands

The attrib command is often used with many of the Recovery Console commands.
Windows 7 and Windows 8 syntax
Displays or changes file attributes.
ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [+I | -I] [drive:][path]
[filename] [/S [/D] [/L]]
+

Sets an attribute.

Clears an attribute.

Read-only file attribute.

Archive file attribute.

System file attribute.

Hidden file attribute.

Not content indexed file attribute.

No scrub file attribute

Integrity attribute.

/S

Processes matching files in the current folder and all subfolders.

/D

Process folders as well.

/L

Work on the attributes of the Symbolic Link versus the target of the Symbolic Link

See our attrib examples for information and examples on how to use this
command.
Microsoft Windows 2000 and Windows XP syntax
Displays or changes file attributes.
ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [[drive:] [path] filename]
[/S [/D]]
+

Sets an attribute.

Clears an attribute.

Read-only file attribute.

Archive file attribute.

System file attribute.

Hidden file attribute.

/S

Processes files in all directories in the specified path.

/D

Process folders as well.

See our attrib examples for information and examples on how to use this
command.
Microsoft Windows 2000 and Windows XP recovery console syntax
Note: The below options are the available options in the Windows recovery
console.

Changes attributes on one file or directory.


ATTRIB -R | +R | -S | +S | -H | +H | -C | +C filename
+

Sets an attribute.

Clears an attribute.

Read-only file attribute.

System file attribute.

Hidden file attribute.

Compressed file attribute.

See our attrib examples for information and examples on how to use this
command.
Microsoft Windows 95, 98, and ME syntax
Displays or changes file attributes.
ATTRIB [+R | -R] [+A | -A] [+S | -S] [+H | -H] [[drive:][path]filename] [/S]
+

Sets an attribute.

Clears an attribute.

Read-only file attribute.

Archive file attribute.

System file attribute.

Hidden file attribute.

/S

Processes files in all directories in the specified path.

Examples
attrib

Typing attrib by itself displays all files in the current directory and each of
their attributes. If any file is hidden it also displays those files.

As can be seen in the above example we typed the dir command to list the
files in the current directory and could only see the "computer.bat" file listed.
However, when we type attrib by itself, we can see that there are three files
in this directory, "computer.bat" with read-only, "example.txt" with hidden,
and "hope.txt" with the hidden and read-only attribute.

attrib +r autoexec.bat

Add the read-only attribute to the autoexec.bat file so it cannot be modified


until the read-only attribute is taken off. This is helpful for important system
files or any other file that you do not want to have mistakenly edited or
changed by another program.
attrib +h config.sys

Add the hidden attribute to the config.sys file causing it to be not be seen by
the average user.
attrib -h config.sys

This command does the opposite of the example shown before this
command. Instead of hiding the file this command makes the file visible if
hidden.
attrib +r +h autoexec.bat

Finally, this example adds two attributes to the autoexec.bat and makes the
file read-only as well as hidden.

How can I see hidden files in MS-DOS?

Extended information
Most users never need to deal with a files bit position or hex value. However,
for those needing this information when working with MS-DOS and the

Windows command line below are the file attributes bit positions
and Hex Values with bit positions in the order of "7 6 5 4 3 2 1 0."
Bit Positions

Hex

Description

00000001

01h

Read-only file

00000010

02h

Hidden file

00000100

04h

System file

00001000

08h

Volume Label

00010000

10h

Subdirectory

00100000

20h

Archive

01000000

40h

Reserved

10000000

80h

Reserved

00100001

21h

Read-only, Archive

00110010

32h

Hidden, Subdirectory, Archive

00100111

27h

Read-only, Hidden, System file, Archive

00100011

23h

Read-only, Hidden, Archive

Examples

You might also like