Attrib
Encyclopedia
attrib is a command
, in DOS
, OS/2
and Microsoft Windows
. The function of attrib is to set and remove file attribute
s (read-only, archive, system and hidden). These attributes are used by a wide variety of software programs to protect and classify files.
Many users regularly encounter the read-only attribute, which will prevent most software from allowing the user to overwrite or append to a file. Software can be designed to override this option, often after receiving confirmation from the user. The archive attribute is used by various backup and file copy programs as a hint as to whether a file needs to be backed up. The hidden attribute makes affected files invisible in many programs, although a variety of software, especially software designed for listing, viewing, and searching files, allows hidden files to be made visible, often with a notation that they have been designated as hidden. The system attribute is used to designate certain operating system files and affects the operation of most software less than the other attributes.
One or more of these attributes can be set [+x] or cleared [-x] in a single instance of the command for a specific file, file type, folder or and entire branch of the directory structure (a directory, including all sub-directories). There are three optional switches that can be applied at the end of the DOS command string, although not all switches are recognized for all versions of Windows. These switches are:
The general attrib command syntax is:
For example, to remove the read-only and hidden file attributes for all files in a directory tree:
Note, the -s parameter will also remove the system attribute for files and should always be used with care and should not be used for genuine system files.
The command will not clear the Read-Only flag from hidden files and will report that the flag was not cleared on each file.
and Windows Server 2003
, and "/L" (which instructs attrib to work with the attributes of the symbolic link itself instead of the target of the symbolic link) was introduced with Windows Vista
and Windows Server 2008.
Command (computing)
In computing, a command is a directive to a computer program acting as an interpreter of some kind, in order to perform a specific task. Most commonly a command is a directive to some kind of command line interface, such as a shell....
, in DOS
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...
, OS/2
OS/2
OS/2 is a computer operating system, initially created by Microsoft and IBM, then later developed by IBM exclusively. The name stands for "Operating System/2," because it was introduced as part of the same generation change release as IBM's "Personal System/2 " line of second-generation personal...
and Microsoft Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...
. The function of attrib is to set and remove file attribute
File attribute
A file attribute is metadata that describes or is associated with a computer file. For example, an operating system often keeps track of the date a file was created and last modified, as well as the file's size and extension . File permissions are also kept track of...
s (read-only, archive, system and hidden). These attributes are used by a wide variety of software programs to protect and classify files.
Many users regularly encounter the read-only attribute, which will prevent most software from allowing the user to overwrite or append to a file. Software can be designed to override this option, often after receiving confirmation from the user. The archive attribute is used by various backup and file copy programs as a hint as to whether a file needs to be backed up. The hidden attribute makes affected files invisible in many programs, although a variety of software, especially software designed for listing, viewing, and searching files, allows hidden files to be made visible, often with a notation that they have been designated as hidden. The system attribute is used to designate certain operating system files and affects the operation of most software less than the other attributes.
Definition of attrib Command
There are four attributes in Windows files:- (r) Read-only file attribute
- (a) Archive file attribute
- (s) System file attribute
- (h) Hidden file attribute
One or more of these attributes can be set [+x] or cleared [-x] in a single instance of the command for a specific file, file type, folder or and entire branch of the directory structure (a directory, including all sub-directories). There are three optional switches that can be applied at the end of the DOS command string, although not all switches are recognized for all versions of Windows. These switches are:
- /S also apply changes to subdirectories of current directory
- /D also apply changes to folder names (this only applies for Windows 2000Windows 2000Windows 2000 is a line of operating systems produced by Microsoft for use on personal computers, business desktops, laptops, and servers. Windows 2000 was released to manufacturing on 15 December 1999 and launched to retail on 17 February 2000. It is the successor to Windows NT 4.0, and is the...
and Windows XPWindows XPWindows XP is an operating system produced by Microsoft for use on personal computers, including home and business desktops, laptops and media centers. First released to computer manufacturers on August 24, 2001, it is the second most popular version of Windows, based on installed user base...
) - /L apply to symbolic link itself instead of the target of the symbolic link (introduced with Windows VistaWindows VistaWindows Vista is an operating system released in several variations developed by Microsoft for use on personal computers, including home and business desktops, laptops, tablet PCs, and media center PCs...
and Windows Server 2008)
The general attrib command syntax is:
-
- attrib [+r|-r] [+a|-a] [+h|-h] [+s|-s] [d:][path]filename [/s] [/d] [/l]
For example, to remove the read-only and hidden file attributes for all files in a directory tree:
-
- attrib -r -h *.* /s /d
Note, the -s parameter will also remove the system attribute for files and should always be used with care and should not be used for genuine system files.
Particularities
In certain versions, when both the s and h attributes are both set, they can only be removed at the same time. Therefore, to remove only one, both must first be removed, and then the desired attribute can be (re)set, for exampleC:\> attrib -S -H *.*
The command will not clear the Read-Only flag from hidden files and will report that the flag was not cleared on each file.
Differences between Windows versions
The "/D" switch (which recurses into sub-directories) was introduced with Windows XPWindows XP
Windows XP is an operating system produced by Microsoft for use on personal computers, including home and business desktops, laptops and media centers. First released to computer manufacturers on August 24, 2001, it is the second most popular version of Windows, based on installed user base...
and Windows Server 2003
Windows Server 2003
Windows Server 2003 is a server operating system produced by Microsoft, introduced on 24 April 2003. An updated version, Windows Server 2003 R2, was released to manufacturing on 6 December 2005...
, and "/L" (which instructs attrib to work with the attributes of the symbolic link itself instead of the target of the symbolic link) was introduced with Windows Vista
Windows Vista
Windows Vista is an operating system released in several variations developed by Microsoft for use on personal computers, including home and business desktops, laptops, tablet PCs, and media center PCs...
and Windows Server 2008.
See also
-
cacls
MS-Windows NT filesystem ACL control utilityCaclscacls and icacls are Microsoft Windows native command line utilities capable of displaying and modifying the access control lists on folders and files... -
chattr
Unix/Linux equivalentChattrchattr is a command in the Linux operating system that allows a user to set certain attributes on a file residing on an ext2-based filesystem. chflags is the analogous command on modern BSD systems, including Mac OS X. The commands are similar to the attrib command on DOS, OS/2 and Microsoft Windows... - List of DOS commands
External links
- Definition of: DOS Attrib PC MagazinePC MagazinePC Magazine is a computer magazine published by Ziff Davis Publishing Holdings Inc. A print edition was published from 1982 to January 2009...
- Microsoft DOS attrib command