habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Linux Show Folder Size and File in Directory

35 sec read

Hi Dude, This is short article about linux show size file and folder directory. Little tips to show size directory, and print result sort ascending base of size file.

Basicly, this is combine between command du and sort. Function of sort is filtering outoput from big size to tiny size.

du -sh *  | sort -hr

Example like below.

root@hostname:/var/log# du -sh *  | sort -hr

15M     installer
2.5M    syslog.1
2.1M    vmware-caf
440K    syslog
424K    udev
296K    upstart
144K    kern.log.1
120K    syslog.2.gz
112K    syslog.6.gz
112K    syslog.5.gz
108K    syslog.7.gz
108K    syslog.3.gz
100K    dmesg.0
100K    dmesg

Show Size Folder Only

And then Sort the output of the 'du' command by largest first, with using human readable output.

du -h --max-depth=1 | sort -rh

Example like below.

root@hostname:/var/log# du -h --max-depth=1 | sort -rh

22M     .
15M     ./installer
2.1M    ./vmware-caf
296K    ./upstart
40K     ./mysql
28K     ./apt
12K     ./fsck
4.0K    ./unattended-upgrades
4.0K    ./landscape
4.0K    ./dist-upgrade

To see all manual about sort command, type sort -help.


See also  Wget Recursively Download All Files and Folder
habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Centos Failed Update Kernel

Today I did a kernel update on my server with Centos 7 OS. At the end of the update process, I found a kernel...
habibzain
1 min read

Easy Fix Missing mirrorlist http://mirrorlist.centos.org on CentOS 7

When running yum update or command that utilize the yum system, errors similar to the following are produced: If you’re encountering issues with the...
habibzain
1 min read

Easy Create Laravel Project with Composer

Requirement Laravel, a popular PHP framework, is renowned for its elegant syntax and robust features, making it a top choice for web developers. One...
habibzain
1 min read

Leave a Reply

Your email address will not be published. Required fields are marked *

Never miss good article from us, get weekly updates in your inbox