cmd Viewing disk usage


Viewing disk usage and available space in the Windows Command Prompt (cmd) is essential for managing storage, optimizing performance, and troubleshooting issues. Several commands can help you check the disk space, usage, and other related information. Below, I’ll explain the key commands used for viewing disk usage and space, along with examples and expected outputs.

1. Using the dir Command

The dir command lists the contents of a directory, and it also provides information about the total number of files, directories, and the total size of files within that directory.

Basic Syntax:

dir [path]

Example:

To view the contents and disk usage of the current directory, simply enter:

dir

Output:

C:\Users\YourUsername>dir Volume in drive C has no label. Volume Serial Number is XXXX-XXXX Directory of C:\Users\YourUsername 10/29/2024 10:15 AM <DIR> Documents 10/29/2024 10:15 AM <DIR> Downloads 10/29/2024 10:15 AM <DIR> Pictures 10/29/2024 10:15 AM <DIR> Music 10/29/2024 10:15 AM <DIR> Videos 5 File(s) 0 bytes 5 Dir(s) 50,123,456,789 bytes free

Output Explanation:

  • The output displays the directories and files within the current directory, along with the total bytes free on the disk.

2. Using the wmic Command

The wmic (Windows Management Instrumentation Command-line) tool can provide detailed information about disk drives, including available space and total size.

Basic Syntax:

wmic logicaldisk get size,freespace,caption

Example:

To view the total size and free space for all disk drives, enter:

wmic logicaldisk get size,freespace,caption

Output:

C:\Users\YourUsername>wmic logicaldisk get size,freespace,caption Caption FreeSpace Size C: 50212345678 100000000000 D: 1234567890 20000000000

Output Explanation:

  • Caption: The drive letter (e.g., C:, D:).
  • FreeSpace: The available space in bytes.
  • Size: The total size of the disk in bytes.

3. Using the fsutil Command

The fsutil command can provide information about free and total disk space, among other filesystem-related tasks.

Basic Syntax:

fsutil volume diskfree [drive: ]

Example:

To view the disk space for drive C, enter:

fsutil volume diskfree C:

Output:

C:\Users\YourUsername>fsutil volume diskfree C: Total # of free bytes : 50212345678 Total # of bytes : 100000000000

Output Explanation:

  • Total # of free bytes: The amount of free space available on the drive.
  • Total # of bytes: The total capacity of the drive.

4. Using the diskpart Command

The diskpart command is a more advanced tool for disk management. You can use it to view detailed information about all connected drives.

Basic Syntax:

diskpart

Once in the DiskPart command line, use:

list volume

Example:

To start DiskPart and list all volumes, enter:

diskpart

Then, in the DiskPart prompt:

list volume

Output:

C:\Users\YourUsername>diskpart Microsoft DiskPart version X.X Copyright (C) Microsoft Corporation. On computer: YOUR-PC DISKPART> list volume Volume ### Ltr Label Fs Type Size Status Info ---------- --- ----- ----- ----------- ------- --------- -------- Volume 0 C OS NTFS Partition 100 GB Healthy Volume 1 D Data NTFS Partition 200 GB Healthy

Output Explanation:

  • Volume ###: The volume number.
  • Ltr: The drive letter assigned to the volume.
  • Label: The label of the volume (if any).
  • Fs: The file system used (e.g., NTFS).
  • Type: Indicates whether the volume is a partition or a removable drive.
  • Size: The total size of the volume.
  • Status: The health status of the volume.

Summary

Viewing disk usage and available space in the Windows Command Prompt can be accomplished using several commands such as dir for basic directory and file size information, wmic for detailed drive statistics, fsutil for specific disk space queries, and diskpart for advanced disk management. Understanding how to view and manage disk space is crucial for maintaining system performance and optimizing storage usage.