Information Technology Grimoire

Version .0.0.1

IT Notes from various projects because I forget, and hopefully they help you too.

df and du Disk Space

total disk space

df -h / | grep "/" | awk '{ print $5 }' | sed 's/%//g'
digitalcrunch@penguin:/var/log$ df -h / | grep "/" | awk '{ print $5 }' | sed 's/%//g'
40
digitalcrunch@penguin:/var/log$ df -h / 
Filesystem      Size  Used Avail Use% Mounted on
/dev/vdb         27G   11G   16G  40% /

Summary of

digitalcrunch@penguin:/var/log$ du -sh `sudo ls -d */` | sort -n
du: cannot read directory 'private/': Permission denied
0       private/
0       runit/
20K     citrix/
208M    journal/
328K    apt/

investigation

du -hsx --exclude=/{proc,sys,dev,run} /* | sort -r -n
root@somesite:~# du -hsx --exclude=/{proc,sys,dev,run} /* | sort -r -n
358M    /root
180K    /home
108M    /boot
84K     /tmp
24K     /snap
17M     /opt
16K     /lost+found
7.8M    /etc
4.0K    /srv
4.0K    /mnt
4.0K    /media
2.9G    /var
2.4G    /usr
2.1G    /swapfile
0       /sbin
0       /libx32
0       /lib64
0       /lib32
0       /lib
0       /bin
root@somesite:~# du -sx --exclude=/{proc,sys,dev,run} /var/www/* | sort -r -n
969988  /var/www/html
178532  /var/www/logs
root@somesite:~# du -sx --exclude=/{proc,sys,dev,run} /var/www/html/* | sort -r -n
769300  /var/www/html/somesite.com
200684  /var/www/html/sellyourhomefastonline.com
0       /var/www/html/index.html
root@somesite:~# du -sx --exclude=/{proc,sys,dev,run} /var/www/html/somesite.com/* | sort -r -n
692296  /var/www/html/somesite.com/wp-content
48612   /var/www/html/somesite.com/wp-includes
18140   /var/www/html/somesite.com/t
10024   /var/www/html/somesite.com/wp-admin
52      /var/www/html/somesite.com/wp-login.php
36      /var/www/html/somesite.com/wp-signup.php
28      /var/www/html/somesite.com/wp-settings.php
20      /var/www/html/somesite.com/license.txt
12      /var/www/html/somesite.com/wp-mail.php
8       /var/www/html/somesite.com/wp-trackback.php
8       /var/www/html/somesite.com/wp-cron.php
8       /var/www/html/somesite.com/wp-activate.php
8       /var/www/html/somesite.com/readme.html
4       /var/www/html/somesite.com/xmlrpc.php
4       /var/www/html/somesite.com/wp-load.php
4       /var/www/html/somesite.com/wp-links-opml.php
4       /var/www/html/somesite.com/wp-config.php
4       /var/www/html/somesite.com/wp-config-sample.php
4       /var/www/html/somesite.com/wp-comments-post.php
4       /var/www/html/somesite.com/wp-blog-header.php
4       /var/www/html/somesite.com/wordfence-waf.php
4       /var/www/html/somesite.com/index.php
4       /var/www/html/somesite.com/ahrefs_6a3c2e9889738225e6e915d5525bb96140fe730158b5dba53a7491143c6e1a6e
root@somesite:~# du -sx --exclude=/{proc,sys,dev,run} /var/www/html/somesite.com/wp-content/* | sort -r -n
622596  /var/www/html/somesite.com/wp-content/uploads
55108   /var/www/html/somesite.com/wp-content/plugins
7680    /var/www/html/somesite.com/wp-content/wflogs
6864    /var/www/html/somesite.com/wp-content/themes
32      /var/www/html/somesite.com/wp-content/cache
4       /var/www/html/somesite.com/wp-content/upgrade
4       /var/www/html/somesite.com/wp-content/index.php
4       /var/www/html/somesite.com/wp-content/autoptimize_404_handler.php
root@somesite:~# du -sxh --exclude=/{proc,sys,dev,run} /var/www/html/somesite.com/wp-content/* | sort -r -n
609M    /var/www/html/somesite.com/wp-content/uploads
54M     /var/www/html/somesite.com/wp-content/plugins
32K     /var/www/html/somesite.com/wp-content/cache
7.5M    /var/www/html/somesite.com/wp-content/wflogs
6.8M    /var/www/html/somesite.com/wp-content/themes
4.0K    /var/www/html/somesite.com/wp-content/upgrade
4.0K    /var/www/html/somesite.com/wp-content/index.php
4.0K    /var/www/html/somesite.com/wp-content/autoptimize_404_handler.php
root@somesite:~# du -hsx --exclude=/{proc,sys,dev,run} /var/www/* | sort -r -n
948M    /var/www/html
175M    /var/www/logs