Disk Space

View available disk space on your system

Size of directories

You can use du to see the size of directories. For example, du animals will print the size of the animals directory and the size of every subdirectory within it.

However, it is not very useful because it prints the sizes in bytes. To show human-readable sizes like GB, MB, etc, use the -h flag.

You might also want to include files in the output, not only directories. To do that, use the -a flag.

If the directory is large and has many subdirectories, the output becomes very cluttered. Then, the -d flag comes in handy. It hides output for deeply nested directories:

        $ du -d 1 animals
        
      

Only show output for files that are placed immediately in the animals directory

In general, -d N includes files that are at most N levels deep in the directory structure.

You can combine these flags to conveniently find out what is taking up the most space inside the animals directory: du -had 1 animals.

System-wide disk space

du can be quite slow for large directories because it iterates over all the files. If all you want to know is the available disk space on your system, use the df command instead:

        $ df -h
        
          
            Filesystem      Size  Used Avail Use% Mounted on
          
            /dev/nvme1n1p2  428G  325G   82G  80% /
          
        
      

Shows the available disk space on each partition

Find the entry where the Mounted on value is /. That is the partition where all your files and applications are stored.