Command referenceattrib
attrib command (Windows / CMD)
What it does
View or change read-only, hidden, system, and archive file attributes. Searches for the attrib command cmd usually need CMD syntax, practical switches, and notes on how it compares with PowerShell or Linux alternatives. This page covers syntax, common options, and copyable examples for Command Prompt.
View or change read-only, hidden, system, and archive file attributes.
Syntax
attrib [+R|-R] [+A|-A] [+S|-S] [+H|-H] [path] [/S] [/D]
Common options
| Flag / option | Meaning |
|---|---|
| +R / -R | Set or clear read-only. |
| +H / -H | Set or clear hidden. |
| +S / -S | Set or clear system. |
| /S | Process matching files in subdirectories. |
| /D | Include directories. |
Practical examples
Show attributes
attrib report.txt
Displays attributes for the file.
Hide file
attrib +H notes.txt
Sets the hidden attribute.
Clear read-only tree
attrib -R C:\Data\* /S /D
Clears read-only below Data.
Linux ↔ Windows equivalent
Closest match: chmod (Linux / bash / sh / zsh). Change file permission bits and special modes.
attrib controls Windows attributes; chmod controls Unix permission bits.
Common mistakes
- Treating attributes as access-control permissions.
- Applying `/S /D` to a broader path than intended.
Related commands
- chmodChange file permission bits and special modes.
- dirList files and subdirectories with names, dates, sizes, and attributes.
- chkdskCheck a volume's filesystem and optionally repair logical or physical errors.
- sudoRun an authorized command with another user's privileges.
- chownChange the owning user and group of filesystem entries.
FAQ
What does attrib do in Command Prompt?
View or change read-only, hidden, system, and archive file attributes.
How do I run attrib in CMD?
Open Command Prompt and follow `attrib [+R|-R] [+A|-A] [+S|-S] [+H|-H] [path] [/S] [/D]`; quote paths containing spaces.
What is a practical attrib example in CMD?
Try `attrib report.txt` — Displays attributes for the file.
Can attrib be used in a batch file?
Yes. Check its exit code and escape CMD metacharacters when input is variable.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.