Linux Disk Usage cPanel Heads Up Tutorial

Linux Disk Usage cPanel Heads Up Tutorial

Linux Disk Usage cPanel Heads Up Tutorial

What’s important, and what’s not? Leave you with that. See you tomorrow.

Not a very good blog posting is it? Let’s say, instead …


"What's important, and what's not, regarding Linux CentOS WHM Apache/PHP/MySQL cPanel, when it presents one of its very rare error messages?"

… and say, from today’s experience, take the time to “follow up on it” and “follow up on it now”. Guess the lesson, in life, here, too, is that in order to appreciate the “quiet achieving things in life” to the utmost “give them their due” if they ever do, as ever, not be wasting your time, and are displaying or showing something unusual to (really) tell you (something important).

So what was our case today? The Linux CentOS WHM cPanel system is a very clever one, and in default usage, tends to want to keep your cPanel software up to date, like you might be familiar with Windows doing, though cPanel, by default, one of the best “quiet achieving things in life” (not that Windows isn’t, by the way) tends to do this updating quite surreptitiously. Today, though, going into cPanel we got the top right scenario of today’s tutorial picture, featuring a yellow error box, the first one I’d ever seen cPanel present, with the wording …


The last attempt to update cPanel and WHM was blocked. Details.

Now the word “blocked” is interesting these days (and all the other days, as well). The more sensationally minded of us think “catastrophe”, and think malware, hacking, and other catastrophic things, but am here to tell you that “blocked” can be a thing that happens for a good “protective” reason, cPanel being such a benign and useful tool, it is infinitely better to click on Details and not “bury your head in the sand”, as I find out.

So, what panned out to be the “blocking” reason? Lack of disk space to perform one of cPanel’s surreptitious upgrades, that’s the reason. And gasp, yes, “ssh”ing onto the web server and going “du -k /” showing 99% usage. Ugh!

And as bad as all this is, there is a focussing of the mind, and problem, but only if you don’t bury your head in the sand.

Which brings us onto the previous Linux Disk Usage Statistics Primer Tutorial where we discussed tactics for just this issue, “ssh”ing to the web server and typing …

$ du -a [DocumentRoot] 2> /dev/null | sort -n -r | head -10

… where [DocumentRoot] is where HTTP://www.rjmprogramming.com.au/ points to, directory (ie. folder) wise (in regard to the web server system disk).

And the resultant report made us realize “back in the day” when we presented Joomla Categories and Articles and Menus Primer Tutorial a new Joomla website became necessary with an upgrade of PHP, I think it was, and at the time, while the new Joomla website was being bedded in, didn’t want to delete the files of the old Joomla. However, that decision, in particular, had come home to … well, you know the expression?! And here is another thing about Apache/PHP/MySQL web servers, and I dare say other web server architectures, that the individual website directories (ie. folders) each pointing to not subdomains exactly but individual websites, as with our blogs and CMS and eCommerce website “products” here at RJM Programming each have the potential to build up huge error_log files not controlled in a rotational sense like the log files of /var/log for instance, by cPanel or some other overseer, and given no scrutiny by the web server manager to write some script to check on this, sometimes these “error_log” files can become huge, and I mean “huge”. Take a look at, factoring in the kB units …


$ du -a [DocumentRoot] 2> /dev/null | sort -n -r | head -10
20082532 [DocumentRoot]
11666800 [DocumentRoot]/myfavourites
6184280 [DocumentRoot]/myfavourites/administrator
6176472 [DocumentRoot]/myfavourites/administrator/error_log
5413304 [DocumentRoot]/myfavourites/error_log

864352 [DocumentRoot]/Mac
641408 [DocumentRoot]/PHP
593124 [DocumentRoot]/mycustomerportal
515244 [DocumentRoot]/mycustomerportal/error_log
392912 [DocumentRoot]/HTMLCSS

… ugh! All obsolete now, as long as we just leave the (one) old redirecting Joomla index.php (file) pointing to new Joomla and so we could “ssh” to the web server and use an “rm” command, but for file removal “chunks” like this, especially ones where you want to leave just “one file standing” we prefer, believe it or not, to use the “(s)ftp” tool we use, which, these days, is FileZilla (see also FileZilla Secure ftp Primer Tutorial) and use its “GUI feel” to supervise, what we want to be deliberately trepidatious regarding, the “removal of web server files” “in bulk”.


Previous relevant Linux Disk Usage Statistics Primer Tutorial is shown below.

Linux Disk Usage Statistics Primer Tutorial

Linux Disk Usage Statistics Primer Tutorial

There are occasions when using a Linux or Unix operating system when it is gobsmacking how a two letter command can do so much. And so it is the case with our use of the “du” to display disk usage statistics via the incarnation …

$ du -a /

… to display a whole disk from its root directory ( / ) and up, reporting on the disk usage for all the files it encounters.

Putting this in context for how it could be useful to track down, perhaps, major inode usage (ie. lots of files being created) somewhere. In this scenario we say that we might want to narrow the search to the top 15 files (which are perhaps directories, as you might know from your Unix and/or Linux training) via …

$ du -a / 2> /dev/null | sort -n -r | head -15

… and on our local MAMP web server (of a MacBook Pro) we got

$ du -a / 2> /dev/null | sort -n -r | head -15
463218232 /
183397888 /Users
183393240 /Users/user
173735704 /Library
155636160 /Library/pgAgent
139676416 /Users/user/Desktop
139661920 /Users/user/Desktop/NS15148
109587848 /Users/user/Desktop/NS15148/robertmetcalfe
66994504 /Library/pgAgent/Downloads
48401968 /Applications
44435304 /Library/pgAgent/Library
27955056 /Users/user/Desktop/NS15148/robertmetcalfe/Downloads
27639928 /opt
26857192 /opt/local
26839216 /Library/pgAgent/VirtualBox VMs

… and just to put a little intelligence into this have a look at the “file” command as a means to show a file type, and the marvellous “awk” integration of all this via its “system()” method …

$ du -a / 2> /dev/null | sort -n -r | head -15 | awk -F"\t" '{ print $1, FS, system("file \"" $2 $3 $4 $5 "\""); }' | grep -v '^[0| ]' | sed '/:/s// ... is a/g'
463218232 / ... is a directory
183397888 /Users ... is a directory
183393240 /Users/user ... is a directory
173735704 /Library ... is a directory
155636160 /Library/pgAgent ... is a directory
139676416 /Users/user/Desktop ... is a directory
139661920 /Users/user/Desktop/NS15148 ... is a directory
109587848 /Users/user/Desktop/NS15148/robertmetcalfe ... is a directory
66994504 /Library/pgAgent/Downloads ... is a directory
48401968 /Applications ... is a directory
44435304 /Library/pgAgent/Library ... is a directory
27955056 /Users/user/Desktop/NS15148/robertmetcalfe/Downloads ... is a directory
27639928 /opt ... is a directory
26857192 /opt/local ... is a directory
26839216 /Library/pgAgent/VirtualBox VMs ... is a directory

If this was interesting you may be interested in this too.


If this was interesting you may be interested in this too.

This entry was posted in eLearning, Operating System, Tutorials and tagged , , , , , , , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>