CMD Master
Back to Blog
Arnošt Havelka

Attrib Command

Manage file attributes like Read-only, Hidden, and System.

Start Interactive Lesson
Attrib Command

Attrib Command

The attrib command displays, sets, or removes attributes assigned to files or directories. These attributes control how the operating system interacts with files—making them read-only to prevent editing, hiding them from view, or marking them as system files.

Usage:attrib
[+|-attribute]
[drive:][path]filename
[/s /d]
+r / -r
Sets (+) or removes (-) Read-only attribute.
+h / -h
Sets (+) or removes (-) Hidden attribute.
+s / -s
Sets (+) or removes (-) System attribute.
/s
Processes matching files in the current folder and all subfolders.
/d
Processes folders as well (requires /s).

Common Attributes

Real-World Examples

1. Making a file Read-only

Protect an important document from accidental changes.

Command Prompt
C:\Users\User>attrib +r crucial_data.txt

Check the attribute:

Command Prompt
C:\Users\User>attrib crucial_data.txt

2. Hiding a private folder

Hide a folder from casual view.

Command Prompt
C:\Users\User>attrib +h SecretFolder

3. Removing all attributes from all files in a folder

Useful when recovering files from a backup that might have weird permissions set.

Command Prompt
C:\Users\User>attrib -r -h -s *.* /s

Knowledge Check

1 / 3

Which flag makes a file Read-Only?