How to get the size of a directory using the command line in Linux

H

How Can We Help?

How to get the size of a directory using the command line in Linux

  1. Open a new Terminal Window and type the following command:
    du -shc folderPath

    Explanation of the du command:

    du - estimate file space usage
    
    -s, --summarize, display only a total for each argument
    -h, --human-readable, print sizes in human readable format (e.g., 1K 234M 2G)
    -c, --total, produce a grand total
    

     

  2. Replace folderPath with the folder to check the size on.

About the author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

About Author

Ian Carnaghan

I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment.

Follow Me