Viewing the size of files and available storage

Programs and services can behave unexpectedly or stop working entirely when storage space runs tight, so it's important to know how much space is available on our system. This recipe introduces a handful of commands used to determine how large your files and directories are and how much storage is used and is available.

Getting ready

This recipe requires a working CentOS system. Administrative privileges may be needed depending on the permissions of the directories and files you want to inspect.

How to do it...

  • To display the storage capacity of a mounted filesystem, use the df command:
    df -h /
    
  • To view the size of a file, use the ls command:
    ls -sh file.txt
    
  • To determine the size of a directory (the sum ...

Get CentOS 7 Server Deployment Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.