How to get directory size on CentOS and RHEL 6/7 using du command step by step guide


How to get  directory size  on CentOS and RHEL 6/7 using du command  step by step guide

In this article we will learn how to get size of  directory  on linux system which is very common task for a linux administrator to troubleshoot regarding space related issue of hard drive . We can get directory size using du command.
How to get  directory size  on CentOS and RHEL 6/7 using du command  step by step guide
How to get  directory size  on CentOS and RHEL 6/7 using du command  step by step guide

Syntax to get directory size on CentOS and RHEL  linux system


To get directory size the basic syntax is given below

#du <option> <dir name>

Lets take an example we are going to get size of directory name testdir without option then we execute the below command.

#du  testdir

[root@localhost project]# du testdir/
4       testdir/

How to get size of   directory in human readable format on linux system

To get directory size in human readable format we use –h flag like this

#du –h testdir
[root@localhost project]# du -h  testdir/
4.0K    testdir/
 

How to get size of   directory in summarize format on linux system

To get directory size in summarize format we use –s flag like this

#du –s testdir
[root@localhost project]# du -s  testdir/
16      testdir/

 How to get size of  all file and  directory on linux system

To get the size of all files and directory we use –a flag like this.

# du -a  testdir/
[root@localhost project]# du -a  testdir/
4       testdir/test2
4       testdir/test3
4       testdir/test1
16      testdir/

How to get  total size directory on linux system

To get total size of directory we use –c flag like this

# du -c  testdir/
[root@localhost project]# du -c  testdir/
16      testdir/
16      total

 
That’s all. If this article is helpful please share it!!!!




SHARE

Admin

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment