Skip to main content

Command referenceattrib

attrib command (Windows / CMD)

WindowsCMDpermissionsbeginner

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 / optionMeaning
+R / -RSet or clear read-only.
+H / -HSet or clear hidden.
+S / -SSet or clear system.
/SProcess matching files in subdirectories.
/DInclude 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.

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.