{"id":31600,"date":"2017-07-21T03:01:35","date_gmt":"2017-07-20T17:01:35","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=31600"},"modified":"2017-10-08T09:43:51","modified_gmt":"2017-10-07T23:43:51","slug":"linux-disk-usage-cpanel-heads-up-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/linux-disk-usage-cpanel-heads-up-tutorial\/","title":{"rendered":"Linux Disk Usage cPanel Heads Up Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Linux\/linux_du_cpanel.jpg\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Linux Disk Usage cPanel Heads Up Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Linux\/linux_du_cpanel.jpg\" title=\"Linux Disk Usage cPanel Heads Up Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Linux Disk Usage cPanel Heads Up Tutorial<\/p><\/div>\n<p>What&#8217;s important, and what&#8217;s not?  Leave you with that.  See you tomorrow.<\/p>\n<p>Not a very good blog posting is it?  Let&#8217;s say, instead &#8230;<\/p>\n<p><code><br \/>\n\"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?\"<br \/>\n<\/code><\/p>\n<p> &#8230; and say, from today&#8217;s experience, take the time to &#8220;follow up on it&#8221; and &#8220;follow up on it now&#8221;.  Guess the lesson, in life, here, too, is that in order to appreciate the &#8220;quiet achieving things in life&#8221; to the utmost &#8220;give them their due&#8221; if they ever do, as ever, not be wasting your time, and are displaying or showing something unusual to (really) tell you (something important).<\/p>\n<p>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 &#8220;quiet achieving things in life&#8221; (not that Windows isn&#8217;t, by the way) tends to do this updating quite surreptitiously.  Today, though, going into cPanel we got the top right scenario of today&#8217;s <a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Linux\/linux_du_cpanel.jpg\" title='Click picture'>tutorial picture<\/a>, featuring a yellow error box, the first one I&#8217;d ever seen cPanel present, with the wording &#8230;<\/p>\n<p><code><br \/>\nThe last attempt to update cPanel and WHM was blocked. <u>Details<\/u>.<br \/>\n<\/code><\/p>\n<p>Now the word &#8220;blocked&#8221; is interesting these days (and all the other days, as well). The more sensationally minded of us think &#8220;catastrophe&#8221;, and think malware, hacking, and other catastrophic things, but am here to tell you that &#8220;blocked&#8221; can be a thing that happens for a good &#8220;protective&#8221; reason, cPanel being such a benign and useful tool, it is infinitely better to click on <u>Details<\/u> and not &#8220;bury your head in the sand&#8221;, as I find out.<\/p>\n<p>So, what panned out to be the &#8220;blocking&#8221; reason? Lack of disk space to perform one of cPanel&#8217;s surreptitious upgrades, that&#8217;s the reason.  And gasp, yes, &#8220;ssh&#8221;ing onto the web server and going &#8220;du -k \/&#8221; showing 99% usage.  Ugh!<\/p>\n<p>And as bad as all this is, there is a focussing of the mind, and problem, but <i><b>only<\/b><\/i> if you don&#8217;t bury your head in the sand.<\/p>\n<p>Which brings us onto the previous <a title='Linux Disk Usage Statistics Primer Tutorial' href='#lduspt'>Linux Disk Usage Statistics Primer Tutorial<\/a> where we discussed tactics for just this issue, &#8220;ssh&#8221;ing to the web server and typing &#8230;<\/p>\n<p><code>$ du -a [DocumentRoot] 2> \/dev\/null | sort -n -r | head -10<\/code><\/p>\n<p> &#8230; where <i>[DocumentRoot]<\/i> is where <i>HTTP:\/\/www.rjmprogramming.com.au\/<\/i> points to, directory (ie. folder) wise (in regard to the web server system disk).<\/p>\n<p>And the resultant report made us realize &#8220;back in the day&#8221; when we presented <a target=_blank href='https:\/\/www.rjmprogramming.com.au\/ITblog\/joomla-categories-and-articles-and-menus-primer-tutorial\/' title='Joomla Categories and Articles and Menus Primer Tutorial'>Joomla Categories and Articles and Menus Primer Tutorial<\/a> 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&#8217;t want to delete the files of the old Joomla.  However, that decision, in particular, had come home to &#8230; 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 <i>not subdomains exactly<\/i> but individual websites, as with our blogs and CMS and eCommerce website &#8220;products&#8221; here at RJM Programming each have the potential to build up huge <i>error_log<\/i> files not controlled in a rotational sense like the log files of <i>\/var\/log<\/i> 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 &#8220;error_log&#8221; files can become huge, and I mean &#8220;huge&#8221;.  <b>Take a look<\/b> at, factoring in the kB units &#8230;<\/p>\n<p><code><br \/>\n$ du -a [DocumentRoot] 2> \/dev\/null | sort -n -r | head -10<br \/>\n20082532\t[DocumentRoot]<br \/>\n11666800\t[DocumentRoot]\/myfavourites<br \/>\n6184280\t[DocumentRoot]\/myfavourites\/administrator<br \/>\n<b>6176472\t[DocumentRoot]\/myfavourites\/administrator\/error_log<br \/>\n5413304\t[DocumentRoot]\/myfavourites\/error_log<\/b><br \/>\n864352\t[DocumentRoot]\/Mac<br \/>\n641408\t[DocumentRoot]\/PHP<br \/>\n593124\t[DocumentRoot]\/mycustomerportal<br \/>\n515244\t[DocumentRoot]\/mycustomerportal\/error_log<br \/>\n392912\t[DocumentRoot]\/HTMLCSS<br \/>\n<\/code><\/p>\n<p> &#8230; ugh!  All obsolete now, as long as we just leave the (one) old redirecting Joomla <a target=_blank title='Redirecting old Joomla' href='http:\/\/www.rjmprogramming.com.au\/myfavourites\/index.php'>index.php<\/a> (file) pointing to <a target=_blank title='New Joomla' href='http:\/\/www.rjmprogramming.com.au\/myfavourites3\/'>new Joomla<\/a> and so we could &#8220;ssh&#8221; to the web server and use an &#8220;rm&#8221; command, but for file removal &#8220;chunks&#8221; like this, especially ones where you want to leave just &#8220;one file standing&#8221; we prefer, believe it or not, to use the &#8220;(s)ftp&#8221; tool we use, which, these days, is <a target=_blank title='FileZilla' href='https:\/\/filezilla-project.org\/'>FileZilla<\/a> (see also <a target=_blank title='FileZilla Secure ftp Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/filezilla-secure-ftp-primer-tutorial\/'>FileZilla Secure ftp Primer Tutorial<\/a>) and use its &#8220;GUI feel&#8221; to supervise, what we want to be deliberately trepidatious regarding, the &#8220;removal of web server files&#8221; &#8220;in bulk&#8221;.<\/p>\n<hr>\n<p id='lduspt'>Previous relevant <a target=_blank title='Linux Disk Usage Statistics Primer Tutorial' href='https:\/\/www.rjmprogramming.com.au\/ITblog\/linux-disk-usage-statistics-primer-tutorial\/'>Linux Disk Usage Statistics Primer Tutorial<\/a> is shown below.<\/p>\n<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Linux\/linux_du.jpg\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Linux Disk Usage Statistics Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Linux\/linux_du.jpg\" title=\"Linux Disk Usage Statistics Primer Tutorial\"  style=\"float:left;\"  \/><\/a><p class=\"wp-caption-text\">Linux Disk Usage Statistics Primer Tutorial<\/p><\/div>\n<p>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 <a target=_blank title='Computerhope information for du' href='http:\/\/www.computerhope.com\/unix\/udu.htm'>&#8220;du&#8221;<\/a> to display disk usage statistics via the incarnation &#8230;<\/p>\n<p><code>$ du -a \/<\/code><\/p>\n<p> &#8230; to display a whole disk from its root directory ( \/ ) and up, reporting on the disk usage for all the files it encounters.<\/p>\n<p>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 &#8230;<\/p>\n<p><code>$ du -a \/ 2> \/dev\/null | sort -n -r | head -15<\/code><\/p>\n<p> &#8230; and on our local MAMP web server (of a MacBook Pro) we got<\/p>\n<p><code>$ du -a \/ 2> \/dev\/null | sort -n -r | head -15<br \/>\n463218232\t\/<br \/>\n183397888\t\/Users<br \/>\n183393240\t\/Users\/user<br \/>\n173735704\t\/Library<br \/>\n155636160\t\/Library\/pgAgent<br \/>\n139676416\t\/Users\/user\/Desktop<br \/>\n139661920\t\/Users\/user\/Desktop\/NS15148<br \/>\n109587848\t\/Users\/user\/Desktop\/NS15148\/robertmetcalfe<br \/>\n66994504\t\/Library\/pgAgent\/Downloads<br \/>\n48401968\t\/Applications<br \/>\n44435304\t\/Library\/pgAgent\/Library<br \/>\n27955056\t\/Users\/user\/Desktop\/NS15148\/robertmetcalfe\/Downloads<br \/>\n27639928\t\/opt<br \/>\n26857192\t\/opt\/local<br \/>\n26839216\t\/Library\/pgAgent\/VirtualBox VMs<br \/>\n<\/code><\/p>\n<p> &#8230; and just to put a little intelligence into this have a look at the <a target=_blank title='Computerhope information for file' href='http:\/\/www.computerhope.com\/unix\/ufile.htm'>&#8220;file&#8221;<\/a> command as a means to show a file type, and the marvellous <a target=_blank title='Computerhope information for awk' href='http:\/\/www.computerhope.com\/unix\/uawk.htm'>&#8220;awk&#8221;<\/a> integration of all this via its &#8220;system()&#8221; method &#8230;<\/p>\n<p><code>$ 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'<br \/>\n463218232 \t \/ ... is a directory<br \/>\n183397888 \t \/Users ... is a directory<br \/>\n183393240 \t \/Users\/user ... is a directory<br \/>\n173735704 \t \/Library ... is a directory<br \/>\n155636160 \t \/Library\/pgAgent ... is a directory<br \/>\n139676416 \t \/Users\/user\/Desktop ... is a directory<br \/>\n139661920 \t \/Users\/user\/Desktop\/NS15148 ... is a directory<br \/>\n109587848 \t \/Users\/user\/Desktop\/NS15148\/robertmetcalfe ... is a directory<br \/>\n66994504 \t \/Library\/pgAgent\/Downloads ... is a directory<br \/>\n48401968 \t \/Applications ... is a directory<br \/>\n44435304 \t \/Library\/pgAgent\/Library ... is a directory<br \/>\n27955056 \t \/Users\/user\/Desktop\/NS15148\/robertmetcalfe\/Downloads ... is a directory<br \/>\n27639928 \t \/opt ... is a directory<br \/>\n26857192 \t \/opt\/local ... is a directory<br \/>\n26839216 \t \/Library\/pgAgent\/VirtualBox VMs ... is a directory<br \/>\n<\/code><\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d19558' onclick='var dv=document.getElementById(\"d19558\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/linux\/\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d19558' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n<hr>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d31600' onclick='var dv=document.getElementById(\"d31600\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/linux\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d31600' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>What&#8217;s important, and what&#8217;s not? Leave you with that. See you tomorrow. Not a very good blog posting is it? Let&#8217;s say, instead &#8230; &#8220;What&#8217;s important, and what&#8217;s not, regarding Linux CentOS WHM Apache\/PHP\/MySQL cPanel, when it presents one of &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/linux-disk-usage-cpanel-heads-up-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,29,37],"tags":[53,85,234,270,337,1753,2346,1750,394,418,2007,469,707,716,2269,1129,1190,1252,1319,1411,1421],"class_list":["post-31600","post","type-post","status-publish","format-standard","hentry","category-elearning","category-operating-system","category-tutorials","tag-access","tag-apache","tag-command-line","tag-cpanel","tag-disk","tag-disk-space","tag-diskspace","tag-document-root","tag-error-log","tag-file","tag-filezilla","tag-ftp","tag-linux","tag-log","tag-operator","tag-sftp","tag-ssh","tag-terminal","tag-tutorial","tag-web-server","tag-website"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/31600"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=31600"}],"version-history":[{"count":9,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/31600\/revisions"}],"predecessor-version":[{"id":31616,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/31600\/revisions\/31616"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=31600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=31600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=31600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}