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  Linux Delete File or Folder Older than x Days
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.

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

Virtualbox Change Storage Size

Changing the storage size of a virtual machine in VirtualBox involves a few steps. Here’s a general guide. Backup your Virtual Machine (VM) Before...
habibzain
35 sec read

Easy Setup Logrotate Nginx Ubuntu

Log rotation is an important aspect of managing log files on a Linux system, including those generated by Nginx. Logrotate is a utility that...
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