You can check disk space in a terminal or command prompt by typing the `df` command followed by the `-h` flag for human-readable output, or the `du` command with the `-sh` flag for a specific folder's size. This allows you to see available storage, used space, and mount points on your system instantly.

What You'll Need

  • A computer running Windows, macOS, or Linux.
  • Access to a command prompt (CMD), terminal (bash/zsh), or PowerShell.
  • A basic understanding of file paths or drive letters.

Step-by-Step

Checking Disk Space on Windows

  1. Press the Windows Key on your keyboard and type cmd. Select the Command Prompt application from the search results. You may need to right-click and choose Run as administrator if you are checking the C: drive, which often requires elevated permissions.
  2. In the black window that opens, type the following command and press Enter:
    df -h
    This command displays the filesystem disk space usage. The -h flag is crucial; it stands for human-readable, converting bytes into gigabytes (GB) and megabytes (MB) so the numbers are easier to read.
  3. Review the output table. The columns typically include Filesystem (the drive or partition name), Size (total capacity), Used (space occupied), Avail (free space), and Mounted on (where the drive is mounted, like C:\).
  4. To check the size of a specific folder, such as your Documents folder, use the du command. Type the following command and press Enter:
    du -sh C:\Users\YourUsername\Documents
    Replace \YourUsername with your actual Windows username. The -s flag sums the size, showing only the total, and -h makes it readable.
  5. If you prefer a graphical interface, you can also open File Explorer, right-click on any drive or folder, and select Properties. The window that pops up will show you the size and free space at the very bottom.

Checking Disk Space on macOS and Linux

  1. Open your terminal application. On macOS, you can find it in the Utilities folder within Applications, or use Spotlight (Cmd + Space) to search for Terminal. On Linux, you can usually find it in your application menu under System Tools or by pressing Ctrl + Alt + T.
  2. Type the df command followed by the -h flag to see the disk usage of all mounted filesystems. Press Enter. The output will look similar to the Windows version but may show different column headers depending on your specific Linux distribution.
  3. Focus on the line corresponding to the root partition, often labeled / or rootfs. Look at the Mounted on column to confirm it is your main system drive. Check the Avail column to see how much space is left. If this number is low (e.g., less than 5% or a very small number of GB), your system is running low on space.
  4. To analyze a specific directory, such as the /var folder, which often stores logs and temporary files, use the du command. Type the following and press Enter:
    du -sh /var
    This will give you the total size of the entire /var directory. You can replace the path with any directory you wish to inspect.
  5. To get a more detailed breakdown of a directory's contents, you can omit the -s flag. For example, du -h /var/log will list the size of every subdirectory within the logs folder. This is useful for identifying which specific subfolder is consuming the most space.

Common Mistakes

One common mistake is relying solely on the Used column in the df output. This column shows the total space occupied by files, but it does not include space reserved for the system's root user (typically 5% on most Linux systems). If you are planning to install large software, you often need to look at the Avail column instead, as that is the space you can actually write to.

Another frequent error is using the df command without the -h flag on Windows. The default output is in bytes, which results in massive numbers like 1073741824, making it difficult to interpret whether you have 1GB or 1TB of free space. Always remember to include the -h flag for human-readable output.

Users on Linux also sometimes confuse the / (root) directory with the home directory (/home). The root directory contains all system files. If you are running out of space on your /home directory but have plenty left on /, it is a sign that you need to clean up your user files rather than resizing the system partition.

Tips

When cleaning up disk space, start with the largest directories. On Linux, the /var and /tmp directories are often culprits. You can use the du command in reverse order to find the biggest folders. For example, running du -h --max-depth=1 / | sort -h will list all top-level directories with their sizes, allowing you to identify the biggest consumer immediately.

On Windows, the WinSxS folder (Win Side-by-Side) can grow very large over time as Windows updates are stored there. While you should be careful deleting files in this folder, using the Windows Update settings to uninstall old updates is a safer way to reclaim that space without risking system instability.

For a quick visual check on any operating system, you can use the graphical file manager to navigate to the drive. Right-clicking the drive icon and selecting Properties provides a pie chart or bar graph of the disk usage, which can be more intuitive than reading a raw table of numbers.