To du or not to du

Home » Article » To du or not to du

Do you have a need for finding out what is taking up all the room on your server? Do you want to figure out what is eating up all your disk space. Of course there are different ways of doing this, for example the ls command.

e.g ls -al

will lists all the files in your directory and where applicable gives you a nice list of the files and directories. It will even show you the size of the files. e.g. if I want to list the following folder:

/var/lib/psa/dumps/domains/danlobo.co.uk

it will give something like the following:

total 772360

drwxr-xr-x 5 root root      4096 Sep  3 11:32 .

drwxr-xr-x 7 root root      4096 Nov 20  2017 ..

-rw-r----- 1 root root   2368593 Aug 13 20:52 backup_apache-files_1808132045.tgz

-rw-r----- 1 root root   2368593 Sep  1 04:51 backup_apache-files_1809010446.tgz

-rw-r----- 1 root root      2283 Aug 13 20:52 backup_conf_1808132045.tgz

-rw-r----- 1 root root      2443 Sep  1 04:52 backup_conf_1809010446.tgz

-rw-r----- 1 root root 172634384 Aug 13 20:48 backup_domainmail_1808132045.tgz

-rw-r----- 1 root root 189080424 Sep  1 04:49 backup_domainmail_1809010446.tgz

-rw------- 1 root root     54122 Nov 20  2017 backup_info_1711201239.xml

-rw------- 1 root root     80517 Aug 13 20:52 backup_info_1808132045.xml

-rw-r----- 1 root root     77945 Sep  1 04:52 backup_info_1809010446.xml

-rw-r----- 1 root root   9503955 Aug 13 20:52 backup_logs_1808132045.tgz

-rw-r----- 1 root root   9886614 Sep  1 04:52 backup_logs_1809010446.tgz

-rw-r----- 1 root root       240 Aug 13 20:52 backup_pd_1808132045.tgz

-rw-r----- 1 root root       240 Sep  1 04:52 backup_pd_1809010446.tgz

-rw-r----- 1 root root   1188696 Aug 13 20:52 backup_statistics_1808132045.tgz

-rw-r----- 1 root root   1252855 Sep  1 04:52 backup_statistics_1809010446.tgz

-rw-r----- 1 root root 402269008 Sep  1 04:51 backup_user-data_1809010446.tgz

drwxr-xr-x 3 root root      4096 Nov 18  2017 databases

drwxr-xr-x 5 root root      4096 Sep  1 04:49 .discovered

drwxr-xr-x 3 root root      4096 Nov 18  2017 sites

Howver if I want to know the size of the folders, ls does not help me here. For this I can use the du command. eg. du -sh * returns:

du -sh *

2.3M backup_apache-files_1808132045.tgz

2.3M backup_apache-files_1809010446.tgz

4.0K backup_conf_1808132045.tgz

4.0K backup_conf_1809010446.tgz

165M backup_domainmail_1808132045.tgz

181M backup_domainmail_1809010446.tgz

56K backup_info_1711201239.xml

80K backup_info_1808132045.xml

80K backup_info_1809010446.xml

9.1M backup_logs_1808132045.tgz

9.5M backup_logs_1809010446.tgz

4.0K backup_pd_1808132045.tgz

4.0K backup_pd_1809010446.tgz

1.2M backup_statistics_1808132045.tgz

1.2M backup_statistics_1809010446.tgz

384M backup_user-data_1809010446.tgz

14M databases

276K sites

 
As you can see, the du or Disk Usuage command is very useful. For example if you would like to see the size of your folders beginning with . such as your .git folder, you can use something like the following:
 

du -sh .git

274M .git

 
 
 

Add new comment

Image CAPTCHA