{"id":120,"date":"2017-04-07T00:00:00","date_gmt":"2017-04-07T00:00:00","guid":{"rendered":"http:\/\/ssdnodes.billabailey.com\/2017\/04\/07\/quick-tip-get-your-ducks-in-a-row\/"},"modified":"2025-05-18T19:13:20","modified_gmt":"2025-05-18T19:13:20","slug":"ducks-vps-disk-space","status":"publish","type":"post","link":"https:\/\/www.ssdnodes.com\/blog\/ducks-vps-disk-space\/","title":{"rendered":"Using &#8216;ducks&#8217; to solve VPS disk space issues"},"content":{"rendered":"<p>Most <a href=\"https:\/\/www.ssdnodes.com\/blog\/7-more-things-to-do-with-your-vps-vpns-and-more\/\">use cases for a VPS<\/a>, like running a website, aren't all that demanding when it comes to hard drive storage space, but there are some obvious exceptions\u2014hosting audio\/video media, backups, large-scale user databases, and more.<\/p>\n<p>For those who <em>might<\/em> run into issues with hard drive space, keeping tabs on what's using the most isn't a bad idea. It just might give you some visibility into what you need to <code>rm<\/code> before you hit the limit.<\/p>\n<p>That's when it's time to bring in the &quot;ducks.&quot;<\/p>\n<p>The <code>df<\/code> command (short for <em>disk free<\/em>) displays the amount of disk space available on every partition that your user has read access to. (You can also use the <code>-h<\/code> argument to makes the output &quot;human readable,&quot; as in display file usage in KB, MB, and so on.)<\/p>\n<pre class=\"hljs\"><code class=\"hljs sql\">$ df\n\/dev\/xyz            30828540 3006136  26249748  11% \/\ndevtmpfs            2097152       0   2097152   0% \/dev\ntmpfs               2097152       4   2097148   1% \/dev\/shm\ntmpfs               2097152   58500   2038652   3% \/run\ntmpfs                  5120       0      5120   0% \/run\/<span class=\"hljs-keyword\">lock<\/span>\ntmpfs               <span class=\"hljs-number\">2097152<\/span>       <span class=\"hljs-number\">0<\/span>   <span class=\"hljs-number\">2097152<\/span>   <span class=\"hljs-number\">0<\/span>% \/<span class=\"hljs-keyword\">sys<\/span>\/fs\/cgroup\n<span class=\"hljs-keyword\">none<\/span>                <span class=\"hljs-number\">2097152<\/span>       <span class=\"hljs-number\">0<\/span>   <span class=\"hljs-number\">2097152<\/span>   <span class=\"hljs-number\">0<\/span>% \/run\/shm\n<\/code><\/pre>\n<p>In contrast, the <code>du<\/code> program (short for <em>disk usage<\/em>) estimates usage under a directory or file system that you specify. By default, it returns disk usage in KB.<\/p>\n<pre class=\"hljs\"><code class=\"hljs shell\"><span class=\"hljs-meta\">$<\/span><span class=\"bash\"> du *<\/span>\n7831    some-file.tar.gz\n23441   directoryA\/subdirectoryY\n183641  directoryA\/subdirectoryZ\n237189    directoryA\/\n464 directoryB\/\n226     directoryC\/subdirectoryX\n832     directoryC\/subdirectoryY\n483     directoryC\/subdirectoryZ\n1541  directoryC\/\n<\/code><\/pre>\n<p>In most cases, the output will be far lengthier than this example. And that's where you can bring in the the &quot;ducks&quot; to help you investigate a little further.<\/p>\n<pre class=\"hljs\"><code class=\"hljs shell\"><span class=\"hljs-meta\">$<\/span><span class=\"bash\"> du -cks *<\/span>\n7831    some-file.tar.gz\n237189  directoryA\/\n464 directoryB\/\n1541  directoryC\/\n247026  total\n<\/code><\/pre>\n<p>The <code>-c<\/code> argument displays the total usage, <code>-k<\/code> sets the block size to 1024 bytes, and <code>-s<\/code> displays a summary for only the current directory, and not any subdirectories.<\/p>\n<p>Now it's possible to more readily see that directoryA is the largest disk hog.<\/p>\n<p>You can take <code>du -cks<\/code> a little further by piping it into a few other commands, like <code>sort<\/code> and <code>head<\/code>. The following command will sort the results from largest to smallest, and reduce the output to only the 10 largest.<\/p>\n<pre class=\"hljs\"><code class=\"hljs ruby\">$ du -cks * <span class=\"hljs-params\">|sort -rn |<\/span>head -<span class=\"hljs-number\">11<\/span>\n<\/code><\/pre>\n<p>Some people like to take this a step further and <a href=\"https:\/\/www.ssdnodes.com\/blog\/quick-tip-using-aliases-for-good\/\">create an alias<\/a> for this command. You can drop the following in your .profile or .zshrc file.<\/p>\n<pre class=\"hljs language-bash\"><code class=\"hljs\"><span class=\"hljs-built_in\"><span class=\"hljs-built_in\">alias<\/span><\/span> ducks=<span class=\"hljs-string\"><span class=\"hljs-string\">'du -cks * |sort -rn |head -11'<\/span><\/span><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re running out of disk space on your VPS, it&#8217;s time to<\/p>\n","protected":false},"author":20,"featured_media":121,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[18],"tags":[],"class_list":["post-120","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/comments?post=120"}],"version-history":[{"count":2,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/120\/revisions"}],"predecessor-version":[{"id":13046,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/posts\/120\/revisions\/13046"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/media\/121"}],"wp:attachment":[{"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/media?parent=120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/categories?post=120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ssdnodes.com\/wp-json\/wp\/v2\/tags?post=120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}