{"id":141830,"date":"2025-10-29T05:58:40","date_gmt":"2025-10-29T03:58:40","guid":{"rendered":"https:\/\/elementor.com\/blog\/?p=141830"},"modified":"2025-10-29T05:58:50","modified_gmt":"2025-10-29T03:58:50","slug":"how-to-check-disk-space-usage-in-linux","status":"publish","type":"post","link":"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/","title":{"rendered":"The Ultimate Guide: How to Check Disk Space Usage in Linux"},"content":{"rendered":"\n<p>When that happens, your database can get corrupted, file uploads fail, caches break, and your entire site can go down. Suddenly, that project you spent months on is offline, and all eyes are on you to fix it. Understanding your Linux server&#8217;s disk space isn&#8217;t just a &#8220;sysadmin task.&#8221; It&#8217;s a fundamental, non-negotiable skill for any serious web creator. This guide will teach you how to monitor your disk space like a pro, from the basics to the advanced commands you need to pinpoint and solve problems quickly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Key Takeaways<\/strong><\/h2>\n\n\n\n<p>Here\u2019s a quick overview of the essential commands and concepts we&#8217;ll cover.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>df -h<\/strong>: Your go-to command. It shows the <strong>overall disk space usage<\/strong> for all mounted filesystems in a &#8220;human-readable&#8221; format (e.g., GB and MB).<\/li>\n\n\n\n<li><strong>du -sh *<\/strong>: The best command for <strong>finding large directories<\/strong>. It shows a &#8220;summary&#8221; (-s) in &#8220;human-readable&#8221; (-h) format for all files and folders (*) in your current location.<\/li>\n\n\n\n<li><strong>df -i<\/strong>: The &#8220;hidden&#8221; space checker. It checks <strong>inode usage<\/strong>. You can run out of inodes (from millions of tiny files) even if you still have disk space, which also breaks your site.<\/li>\n\n\n\n<li><strong>ncdu<\/strong>: A powerful, <strong>interactive disk usage analyzer<\/strong>. If you can install it, it&#8217;s the easiest way to navigate your filesystem and find what&#8217;s eating up space.<\/li>\n\n\n\n<li><strong>find<\/strong>: Your search tool for finding files by specific criteria, such as <strong>files larger than 1GB<\/strong> (find \/ -type f -size +1G).<\/li>\n\n\n\n<li><strong>Common Culprits<\/strong>: The most likely places to find space-hogging files are \/var\/log (log files), \/var\/www\/html (your webroot, especially backup or cache folders), and \/home (user files).<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Why Monitoring Disk Space is Critical for Your Website<\/strong><\/h2>\n\n\n\n<p>Before we jump into the commands, let&#8217;s establish why this is so important. A full disk isn&#8217;t a minor inconvenience. It&#8217;s a catastrophic failure that can lead to data loss.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Preventing Site Crashes and Downtime<\/strong><\/h3>\n\n\n\n<p>The most immediate and painful symptom of a full disk is downtime. When the server&#8217;s root partition has zero bytes free, essential services can no longer write to their logs or pid files. The operating system itself can become unstable.<\/p>\n\n\n\n<p>For your website, this means the web server (like Nginx or Apache) might fail. More critically, your database service (like MySQL or MariaDB) might crash. If it can&#8217;t write to its transaction logs or temporary files, it will stop, taking your entire site down with it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Ensuring Successful Backups and Updates<\/strong><\/h3>\n\n\n\n<p>This is a catch-22 that bites a lot of people. You need backups to protect your site, but backup processes themselves require disk space. A WordPress backup plugin like UpdraftPlus or BackWPup first creates a .zip archive of your site on the server&#8217;s disk <em>before<\/em> uploading it to an external location like Google Drive.<\/p>\n\n\n\n<p>If your disk is 95% full and your site is 10GB, that 10GB backup file will fail to create. The process will error out, and you&#8217;ll be left with no backup, all because you didn&#8217;t have enough temporary space. The same goes for system updates (apt upgrade) or WordPress core, theme, and plugin updates. They all need to <a class=\"wpil_keyword_link\" href=\"https:\/\/elementor.com\/wordpress\/\"   title=\"download\" data-wpil-keyword-link=\"linked\"  data-wpil-monitor-id=\"16268\">download<\/a> and unpack files, which requires free space.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Maintaining Website Performance<\/strong><\/h3>\n\n\n\n<p>Performance isn&#8217;t just about CPU and RAM. Disk I\/O (Input\/Output) is a major factor. When a disk is nearly full, the filesystem has a harder time finding contiguous blocks of space to write new data. This is called fragmentation, and it can slow down disk operations.<\/p>\n\n\n\n<p>For a dynamic, database-driven website, this is bad news. Slow database queries mean slow page loads. For users, this means a sluggish site. For your business, it means higher bounce rates and lower conversions. Furthermore, caching systems (like W3 Total Cache or WP Super Cache) that write static HTML files to the disk will fail, reverting your site to slow, dynamic PHP processing for every single page load.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Identifying Security Issues<\/strong><\/h3>\n\n\n\n<p>A full disk can also be a symptom of a security problem. If a hacker gains access to your server, they might use it to store large illegal files (warez) or create massive spam email queues.<\/p>\n\n\n\n<p>More commonly, a runaway log file growing to 50GB in a few hours can be a sign of a Distributed Denial of Service (DDoS) attack or a bot aggressively scraping your site, with every single request being logged. Monitoring your disk space helps you spot these anomalies before they take you offline.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Understanding the Linux Filesystem: A Quick Refresher<\/strong><\/h2>\n\n\n\n<p>To effectively manage disk space, you need to understand two or three basic concepts about how Linux organizes files.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Everything is a File (Even Devices)<\/strong><\/h3>\n\n\n\n<p>In Linux, almost everything is treated as a file. A directory is just a special file that lists other files. Even your physical hard drive is represented as a file in the \/dev directory (e.g., \/dev\/sda1).<\/p>\n\n\n\n<p>This concept simplifies things. We can use the same set of tools to work with all of them. The entire system starts at the &#8220;root&#8221; directory, which is represented by a single slash: <strong>\/<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Key Directories to Know<\/strong><\/h3>\n\n\n\n<p>Every directory under \/ has a specific purpose. When hunting for large files, you&#8217;ll almost always end up in one of these:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\/<\/strong><strong> (root)<\/strong>: The top of the entire filesystem.<\/li>\n\n\n\n<li><strong>\/var<\/strong>: The &#8220;variable&#8221; directory. This is the most common place for disk space issues. It contains log files (\/var\/log), web server roots (\/var\/www), database files (\/var\/lib\/mysql), and temporary files (\/var\/tmp).<\/li>\n\n\n\n<li><strong>\/home<\/strong>: Contains the personal directories for each user on the system. If you give other users accounts, their Downloads or Documents folders live here.<\/li>\n\n\n\n<li><strong>\/tmp<\/strong>: A general-purpose temporary directory. Files here are often (but not always) deleted on reboot.<\/li>\n\n\n\n<li><strong>\/mnt<\/strong> or <strong>\/media<\/strong>: Common locations where external drives (like USB sticks or network shares) are &#8220;mounted.&#8221;<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>What Are Filesystems and Mount Points?<\/strong><\/h3>\n\n\n\n<p>This is the most important concept. You might have one physical 500GB hard drive in your server, but it could be partitioned into several &#8220;filesystems.&#8221;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A <strong>filesystem<\/strong> is a formatted partition that holds files (e.g., \/dev\/sda1).<\/li>\n\n\n\n<li>A <strong>mount point<\/strong> is the directory where that filesystem is attached.<\/li>\n<\/ul>\n\n\n\n<p>For example, your 500GB drive could be split:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>A 50GB filesystem for \/ (the root OS).<\/li>\n\n\n\n<li>A 450GB filesystem for \/var\/www (your websites).<\/li>\n<\/ol>\n\n\n\n<p>If you run out of space on the 50GB filesystem, your OS will crash, even though you have 400GB free on the other partition! This is why simply knowing the &#8220;total disk space&#8221; isn&#8217;t enough. You need to know the space <em>per mount point<\/em>.<\/p>\n\n\n\n<p>This is where our first command, df, comes in.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>The Big Picture: Checking Overall Disk Space with <\/strong><strong>df<\/strong><\/h2>\n\n\n\n<p>The df command stands for &#8220;disk free.&#8221; It is the primary tool for checking the usage of all mounted filesystems. It tells you the high-level overview of all your &#8220;drives.&#8221;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Your First Command: <\/strong><strong>df<\/strong><\/h3>\n\n\n\n<p>If you just type df and hit Enter, you&#8217;ll get something like this:<\/p>\n\n\n\n<p>Filesystem &nbsp; &nbsp; 1K-blocks&nbsp; &nbsp; &nbsp; Used Available Use% Mounted on<\/p>\n\n\n\n<p>\/dev\/sda1 &nbsp; &nbsp; &nbsp; 51475068&nbsp; 40113836 &nbsp; 8724788&nbsp; 83% \/<\/p>\n\n\n\n<p>udev &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 10240 &nbsp; &nbsp; &nbsp; &nbsp; 0 &nbsp; &nbsp; 10240 &nbsp; 0% \/dev<\/p>\n\n\n\n<p>tmpfs &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 404184&nbsp; &nbsp; &nbsp; 1200&nbsp; &nbsp; 402984 &nbsp; 1% \/run<\/p>\n\n\n\n<p>\/dev\/sdb1&nbsp; &nbsp; &nbsp; 460305884 210452312 226315668&nbsp; 49% \/var\/www<\/p>\n\n\n\n<p>This output is functional, but not very friendly. The 1K-blocks column shows the size in 1-kilobyte blocks. Nobody wants to do that math.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Making <\/strong><strong>df<\/strong><strong> Human-Readable with <\/strong><strong>df -h<\/strong><\/h3>\n\n\n\n<p>This is the command you will use 99% of the time. The -h flag stands for &#8220;human-readable,&#8221; and it&#8217;s a game-changer.<\/p>\n\n\n\n<p><strong>Command:<\/strong> df -h<\/p>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<p>Filesystem&nbsp; &nbsp; &nbsp; Size&nbsp; Used Avail Use% Mounted on<\/p>\n\n\n\n<p>\/dev\/sda1&nbsp; &nbsp; &nbsp; &nbsp; 49G &nbsp; 39G&nbsp; 8.4G&nbsp; 83% \/<\/p>\n\n\n\n<p>udev &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 10M &nbsp; &nbsp; 0 &nbsp; 10M &nbsp; 0% \/dev<\/p>\n\n\n\n<p>tmpfs &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 395M&nbsp; 1.2M&nbsp; 394M &nbsp; 1% \/run<\/p>\n\n\n\n<p>\/dev\/sdb1 &nbsp; &nbsp; &nbsp; 439G&nbsp; 201G&nbsp; 216G&nbsp; 49% \/var\/www<\/p>\n\n\n\n<p>This is so much better. Let&#8217;s break it down line by line.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Filesystem<\/strong>: The name of the underlying device partition. tmpfs is a temporary, in-memory filesystem.<\/li>\n\n\n\n<li><strong>Size<\/strong>: The total size of this filesystem.<\/li>\n\n\n\n<li><strong>Used<\/strong>: The amount of space currently used.<\/li>\n\n\n\n<li><strong>Avail<\/strong>: The amount of space still available.<\/li>\n\n\n\n<li><strong>Use%<\/strong>: The used space as a percentage. <strong>This is the most important column.<\/strong> You should start to worry when this hits 85-90%.<\/li>\n\n\n\n<li><strong>Mounted on<\/strong>: The directory where this filesystem is attached.<\/li>\n<\/ul>\n\n\n\n<p>From this output, we can instantly learn:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>The main OS partition (\/dev\/sda1, mounted on \/) is 49GB in size and is <strong>83% full<\/strong>. This is getting high.<\/li>\n\n\n\n<li>The website partition (\/dev\/sdb1, mounted on \/var\/www) is 439GB and is only 49% full. There is no space problem here.<\/li>\n<\/ol>\n\n\n\n<p>The problem is on the main drive, not the website drive. We are probably dealing with log files or system packages, not website media.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Advanced <\/strong><strong>df<\/strong><strong> Options for Deeper Insights<\/strong><\/h3>\n\n\n\n<p>While df -h is your daily driver, a few other flags are essential for troubleshooting.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>df -H<\/strong>: Use this if you prefer &#8220;metric&#8221; (powers of 1000) over &#8220;binary&#8221; (powers of 1024). This means 1G = 1000MB, not 1024MB. It can be slightly less confusing.<\/li>\n\n\n\n<li><strong>df -T<\/strong>: This shows the <strong>filesystem type<\/strong> (e.g., ext4, xfs, ntfs). This is useful for debugging or seeing if you&#8217;re working with a Windows partition.<\/li>\n\n\n\n<li><strong>df -i<\/strong>: This checks <strong>inode usage<\/strong>. This is the critical &#8220;hidden&#8221; disk space problem.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>The Inode Problem: <\/strong><strong>df -i<\/strong><\/h4>\n\n\n\n<p>You can have a 500GB disk that df -h reports as &#8220;90% free&#8221; but your site is still crashing and giving &#8220;No space left on device&#8221; errors. How? You&#8217;ve run out of <strong>inodes<\/strong>.<\/p>\n\n\n\n<p><strong>What is an Inode?<\/strong> Think of a disk as a giant library. The books are your data (files). The <strong>inode<\/strong> is the card in the card catalog. Each inode is a tiny data structure that stores <em>metadata<\/em> about a file: who owns it, its permissions, and <em>where to find it<\/em> on the disk.<\/p>\n\n\n\n<p><strong>Every single file and directory requires one inode.<\/strong><\/p>\n\n\n\n<p><strong>Why Can You Run Out of Inodes?<\/strong> You are allocated a fixed number of inodes when the filesystem is created. If you create millions and millions of tiny files, you can use up all your &#8220;index cards&#8221; (inodes) before you run out of &#8220;shelf space&#8221; (GB).<\/p>\n\n\n\n<p>This is a <em>very<\/em> common problem with:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>PHP session files (if not cleaned up)<\/li>\n\n\n\n<li>Email queues (millions of tiny spam emails)<\/li>\n\n\n\n<li>Badly configured caching plugins<\/li>\n<\/ul>\n\n\n\n<p><strong>How to Check Inodes:<\/strong> <strong>Command:<\/strong> df -i<\/p>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<p>Filesystem &nbsp; &nbsp; &nbsp; Inodes &nbsp; IUsed&nbsp; &nbsp; IFree IUse% Mounted on<\/p>\n\n\n\n<p>\/dev\/sda1 &nbsp; &nbsp; &nbsp; 3276800 3276798&nbsp; &nbsp; &nbsp; &nbsp; 2&nbsp; 100% \/<\/p>\n\n\n\n<p>\/dev\/sdb1&nbsp; &nbsp; &nbsp; 28835840&nbsp; 584020 28251820&nbsp; &nbsp; 3% \/var\/www<\/p>\n\n\n\n<p>Look at that!<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Our main partition (\/dev\/sda1) has used <strong>100% of its inodes<\/strong> (IUse%).<\/li>\n\n\n\n<li>Even though df -h said it had 8.4GB of space free, it&#8217;s effectively full. It can&#8217;t create a single new file. This is our problem.<\/li>\n\n\n\n<li>Our website partition (\/dev\/sdb1) is perfectly fine, using only 3% of its inodes.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Practical <\/strong><strong>df<\/strong><strong> Scenarios<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>How to check a specific filesystem:<\/strong> df -h \/dev\/sda1<\/li>\n\n\n\n<li><strong>How to check the disk a specific directory lives on:<\/strong> df -h \/var\/www\/html (This won&#8217;t show the size of \/var\/www\/html, but rather the size of the <em>partition<\/em> it lives on, which is \/dev\/sdb1 in our example).<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Finding the Culprits: Pinpointing Large Files and Directories with <\/strong><strong>du<\/strong><\/h2>\n\n\n\n<p>df told us <em>which<\/em> partition is full (our \/ partition). Now we need to find out <em>what<\/em> is filling it up. For this, we use the du command, which stands for &#8220;disk usage.&#8221;<\/p>\n\n\n\n<p>du works differently than df. It recursively walks through directories and sums up the sizes of all the files inside.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Your Second Core Command: <\/strong><strong>du<\/strong><\/h3>\n\n\n\n<p>If you just type du in a directory like \/var, it will spit out the size of <em>every single subdirectory<\/em> in kilobytes. This is an overwhelming and useless flood of text.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>The Essential <\/strong><strong>du<\/strong><strong> Flags: <\/strong><strong>du -sh<\/strong><\/h3>\n\n\n\n<p>Like df, du has a &#8220;human-readable&#8221; flag (-h). It also has a &#8220;summary&#8221; flag (-s) that, instead of showing every subdirectory, just shows you a single grand total for the directory you specify.<\/p>\n\n\n\n<p>Let&#8217;s combine these.<\/p>\n\n\n\n<p><strong>Command:<\/strong> du -sh *<\/p>\n\n\n\n<p>This is one of the most useful commands in Linux. It means:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>s<\/strong>: Summarize the total size<\/li>\n\n\n\n<li><strong>h<\/strong>: in Human-readable format<\/li>\n\n\n\n<li><strong>*<\/strong>: for everything (all files and directories) in the current location.<\/li>\n<\/ul>\n\n\n\n<p>Let&#8217;s cd to our \/var directory (which lives on the full partition) and run it.<\/p>\n\n\n\n<p><strong>Command:<\/strong><\/p>\n\n\n\n<p>cd \/var<\/p>\n\n\n\n<p>du -sh *<\/p>\n\n\n\n<p><strong>Output:<\/strong><\/p>\n\n\n\n<p>4.0K&nbsp; &nbsp; backups<\/p>\n\n\n\n<p>12G &nbsp; &nbsp; cache<\/p>\n\n\n\n<p>4.0K&nbsp; &nbsp; crash<\/p>\n\n\n\n<p>16G &nbsp; &nbsp; lib<\/p>\n\n\n\n<p>4.0K&nbsp; &nbsp; local<\/p>\n\n\n\n<p>0 &nbsp; &nbsp; &nbsp; lock<\/p>\n\n\n\n<p>22G &nbsp; &nbsp; log<\/p>\n\n\n\n<p>4.0K&nbsp; &nbsp; mail<\/p>\n\n\n\n<p>4.0K&nbsp; &nbsp; opt<\/p>\n\n\n\n<p>0 &nbsp; &nbsp; &nbsp; run<\/p>\n\n\n\n<p>4.0K&nbsp; &nbsp; snap<\/p>\n\n\n\n<p>4.0K&nbsp; &nbsp; spool<\/p>\n\n\n\n<p>3.1M&nbsp; &nbsp; tmp<\/p>\n\n\n\n<p>Instantly, we have our suspects. The default files and directories are tiny (4.0K). But look at the big ones:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>cache: 12GB<\/li>\n\n\n\n<li>lib: 16GB<\/li>\n\n\n\n<li>log: 22GB<\/li>\n<\/ul>\n\n\n\n<p>Our 39GB of used space (df -h told us this) is almost entirely in these three directories.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Digging Deeper with <\/strong><strong>du<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>du -h &#8211;max-depth=1<\/strong>: This is an alternative to du -sh *. It shows the size of the current directory (.) and all its children one level deep. It&#8217;s great for drilling down.<\/li>\n\n\n\n<li><strong>du -h &#8211;exclude=*.log<\/strong>: You can exclude certain file types.<\/li>\n\n\n\n<li><strong>du -a<\/strong>: This shows <strong>all files<\/strong>, not just directories.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Citation<\/strong><\/h3>\n\n\n\n<p>As web creators, we often focus on the front-end, but a &#8220;black box&#8221; server is a liability. As Itamar Haim, a long-time web development expert, often says, &#8220;Knowing du and df is as fundamental to managing a modern WordPress site as knowing <a class=\"wpil_keyword_link\" href=\"https:\/\/elementor.com\/blog\/what-is-css\/\"   title=\"CSS\" data-wpil-keyword-link=\"linked\"  data-wpil-monitor-id=\"16269\">CSS<\/a>. You can&#8217;t optimize what you can&#8217;t measure, and that starts with your server&#8217;s disk.&#8221;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>The Power Combo: Sorting <\/strong><strong>du<\/strong><strong> Output<\/strong><\/h3>\n\n\n\n<p>du -sh * is great, but what if you have 100 directories? The biggest one might not be obvious. We can &#8220;pipe&#8221; (|) the output of du directly into the sort command.<\/p>\n\n\n\n<p><strong>Command:<\/strong> du -h &#8211;max-depth=1 | sort -hr<\/p>\n\n\n\n<p>Let&#8217;s break this down:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>du -h &#8211;max-depth=1<\/strong>: Get the disk usage, human-readable, for everything one level deep.<\/li>\n\n\n\n<li><strong>|<\/strong><strong> (the pipe)<\/strong>: This magic character sends the <em>output<\/em> of the first command to be the <em>input<\/em> of the second command.<\/li>\n\n\n\n<li><strong>sort -hr<\/strong>:\n<ul class=\"wp-block-list\">\n<li><strong>h<\/strong>: Sorts &#8220;human-readable&#8221; numbers (so it knows 2G is bigger than 100M).<\/li>\n\n\n\n<li><strong>r<\/strong>: Sort in &#8220;reverse&#8221; order (largest to smallest).<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This single command is the <strong>number one workflow<\/strong> for hunting down space hogs.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Step-by-Step Example: Hunting Down a Bloated Log File<\/strong><\/h4>\n\n\n\n<p>Let&#8217;s use this command to find our 22GB log problem.<\/p>\n\n\n\n<p><strong>Step 1:<\/strong> Start at the root of the problem partition.<\/p>\n\n\n\n<p>$ cd \/<\/p>\n\n\n\n<p>$ du -h &#8211;max-depth=1 | sort -hr<\/p>\n\n\n\n<p>55G &nbsp; &nbsp; .<\/p>\n\n\n\n<p>22G &nbsp; &nbsp; .\/var<\/p>\n\n\n\n<p>16G &nbsp; &nbsp; .\/usr<\/p>\n\n\n\n<p>12G &nbsp; &nbsp; .\/home<\/p>\n\n\n\n<p>5.1G&nbsp; &nbsp; .\/lib<\/p>\n\n\n\n<p>&#8230;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The total size . is 55G.<\/li>\n\n\n\n<li>The biggest culprit is .\/var at 22G.<\/li>\n<\/ul>\n\n\n\n<p><strong>Step 2:<\/strong> Drill down into \/var.<\/p>\n\n\n\n<p>$cd \/var$ du -h &#8211;max-depth=1 | sort -hr<\/p>\n\n\n\n<p>22G &nbsp; &nbsp; .<\/p>\n\n\n\n<p>21G &nbsp; &nbsp; .\/log<\/p>\n\n\n\n<p>600M&nbsp; &nbsp; .\/lib<\/p>\n\n\n\n<p>300M&nbsp; &nbsp; .\/cache<\/p>\n\n\n\n<p>&#8230;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The total size . is 22G.<\/li>\n\n\n\n<li>The vast majority is in .\/log at 21G.<\/li>\n<\/ul>\n\n\n\n<p><strong>Step 3:<\/strong> Drill down into \/var\/log.<\/p>\n\n\n\n<p>$cd \/log$ du -h &#8211;max-depth=1 | sort -hr<\/p>\n\n\n\n<p>21G &nbsp; &nbsp; .<\/p>\n\n\n\n<p>20G &nbsp; &nbsp; .\/nginx<\/p>\n\n\n\n<p>500M&nbsp; &nbsp; .\/syslog<\/p>\n\n\n\n<p>200M&nbsp; &nbsp; .\/mysql<\/p>\n\n\n\n<p>&#8230;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Problem found. nginx is taking up 20G.<\/li>\n<\/ul>\n\n\n\n<p><strong>Step 4:<\/strong> Find the specific file.<\/p>\n\n\n\n<p>$cd \/nginx$ ls -lhS<\/p>\n\n\n\n<p>-rw-r&#8211;r&#8211; 1 root root&nbsp; 20G Oct 29 09:30 access.log.1<\/p>\n\n\n\n<p>-rw-r&#8211;r&#8211; 1 root root 300M Oct 29 09:50 access.log<\/p>\n\n\n\n<p>-rw-r&#8211;r&#8211; 1 root root&nbsp; 50M Oct 29 09:50 error.log<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>(We used ls -lhS here, which lists files, human-readable, sorted by size S).<\/li>\n\n\n\n<li>We&#8217;ve found the single file: access.log.1 is a 20GB monster. This is an old, rotated log file that can likely be deleted.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>The Interactive Solution: Using <\/strong><strong>ncdu<\/strong><strong> for Easy Navigation<\/strong><\/h2>\n\n\n\n<p>If you find the du | sort workflow a bit clunky, there is a much better way: ncdu.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>What is <\/strong><strong>ncdu<\/strong><strong>?<\/strong><\/h3>\n\n\n\n<p>ncdu stands for <strong>NCurses Disk Usage<\/strong>. It&#8217;s a command-line tool with a text-based graphical interface. It scans a directory and then lets you <em>navigate<\/em> through it with your arrow keys, sorted by size. It&#8217;s du and sort on steroids.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>How to Install <\/strong><strong>ncdu<\/strong><\/h3>\n\n\n\n<p>It&#8217;s not installed by default, but it&#8217;s in all major repositories.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Debian\/Ubuntu:<\/strong> sudo apt-get install ncdu<\/li>\n\n\n\n<li><strong>RHEL\/CentOS:<\/strong> sudo yum install ncdu<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Running <\/strong><strong>ncdu<\/strong><\/h3>\n\n\n\n<p>Just type ncdu and the directory you want to scan. It&#8217;s best to scan the partition you know is full.<\/p>\n\n\n\n<p><strong>Command:<\/strong> ncdu \/<\/p>\n\n\n\n<p>It will first scan the disk, which can take a few minutes. When it&#8217;s done, you&#8217;ll see an interactive screen:<\/p>\n\n\n\n<p>&#8212; \/ &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;22.1 GiB [##########] \/var<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;16.2 GiB [####### &nbsp; ] \/usr<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;12.0 GiB [##### &nbsp; &nbsp; ] \/home<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;5.1 GiB [##&nbsp; &nbsp; &nbsp; &nbsp; ] \/lib<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&#8230;<\/p>\n\n\n\n<p>You can use your <strong>arrow keys<\/strong> to move up and down. Press <strong>Enter<\/strong> to drill down into a directory. Press the <strong>left arrow<\/strong> to go back up.<\/p>\n\n\n\n<p>You can also use these keys:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>n: Sort by name<\/li>\n\n\n\n<li>s: Sort by size (default)<\/li>\n\n\n\n<li>d: Delete the selected file or directory (it will ask for confirmation).<\/li>\n\n\n\n<li>i: Show information about the selected item.<\/li>\n<\/ul>\n\n\n\n<p>ncdu is the safest, easiest, and most powerful way to find and clean up large files.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Other Useful Commands for Disk Analysis<\/strong><\/h2>\n\n\n\n<p>df, du, and ncdu are the &#8220;big three,&#8221; but a few other commands are handy in your toolkit.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>ls -lh<\/strong><strong>: The Quick Look<\/strong><\/h3>\n\n\n\n<p>We used this earlier. ls lists files, but with these flags, it&#8217;s more helpful:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>l<\/strong>: Use a &#8220;long&#8221; list format (shows permissions, owner, size, date).<\/li>\n\n\n\n<li><strong>h<\/strong>: Show sizes in &#8220;human-readable&#8221; format.<\/li>\n\n\n\n<li><strong>S<\/strong>: Sort the list by file size, largest first. (Use ls -lhrS to reverse it).<\/li>\n<\/ul>\n\n\n\n<p>This is great for seeing the largest <em>files<\/em> in a single directory.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>stat<\/strong><strong>: The File Investigator<\/strong><\/h3>\n\n\n\n<p>The stat command gives you a brain dump of all metadata for a file. <strong>Command:<\/strong> stat \/var\/log\/nginx\/access.log <strong>Output:<\/strong><\/p>\n\n\n\n<p>&nbsp;File: \/var\/log\/nginx\/access.log<\/p>\n\n\n\n<p>&nbsp;&nbsp;Size: 314572800 &nbsp; Blocks: 614400 &nbsp; &nbsp; IO Block: 4096 &nbsp; regular file<\/p>\n\n\n\n<p>Device: 801h\/2049d&nbsp; &nbsp; Inode: 1310724 &nbsp; &nbsp; Links: 1<\/p>\n\n\n\n<p>&#8230;<\/p>\n\n\n\n<p>This shows you the exact size in bytes, how many blocks it&#8217;s <em>really<\/em> taking up on disk, and its inode number.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>The <\/strong><strong>find<\/strong><strong> Command: Your Ultimate Search Tool<\/strong><\/h3>\n\n\n\n<p>The find command is the most powerful search tool in Linux. It can scan the entire system for files matching complex criteria.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Finding Files by Size<\/strong><\/h4>\n\n\n\n<p>This is its most useful function for us.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Find files over 1GB:<\/strong> find \/ -type f -size +1G<\/li>\n\n\n\n<li><strong>Find files between 100M and 500M:<\/strong> find \/ -type f -size +100M -size -500M<\/li>\n<\/ul>\n\n\n\n<p>Explaining the syntax:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>find \/: Start searching from the root directory \/.<\/li>\n\n\n\n<li>-type f: Only find &#8220;files&#8221; (not directories d or links l).<\/li>\n\n\n\n<li>-size +1G: Find files with a size <em>greater than<\/em> 1 Gigabyte.<\/li>\n\n\n\n<li>-size -500M: Find files <em>less than<\/em> 500 Megabytes.<\/li>\n\n\n\n<li>-size 100k: Find files that are <em>exactly<\/em> 100 Kilobytes.<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Finding Files by Name<\/strong><\/h4>\n\n\n\n<p>find \/var\/www -type f -name &#8220;*.log&#8221; (Find all files ending in .log inside your \/var\/www directory).<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Finding Files by Time<\/strong><\/h4>\n\n\n\n<p>find \/tmp -type f -mtime +30 (Find all files in \/tmp that were <em>modified<\/em> more than 30 days ago). This is great for finding old, stale files.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Combining <\/strong><strong>find<\/strong><strong> with Other Commands<\/strong><\/h4>\n\n\n\n<p>The find command can execute another command on every file it finds.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Find and list:<\/strong> find \/var\/log -type f -name &#8220;*.log&#8221; -size +100M -exec ls -lh {} \\; This finds all .log files over 100M and runs ls -lh on them.<\/li>\n\n\n\n<li><strong>Find and delete (THE DANGEROUS ONE):<\/strong> find \/var\/backups -type f -name &#8220;*.zip&#8221; -mtime +30 -exec rm {} \\; This would find all .zip files in \/var\/backups older than 30 days and <strong>delete them<\/strong>. Double-check <em>before<\/em> you run any find &#8230; -exec rm command.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Common Culprits: Where Does All the Disk Space Go?<\/strong><\/h2>\n\n\n\n<p>After years of managing WordPress servers, I can tell you that 90% of disk space emergencies come from these places.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Runaway Log Files<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Location:<\/strong> \/var\/log\/ (or \/var\/log\/nginx\/, \/var\/log\/apache2\/, etc.)<\/li>\n\n\n\n<li><strong>Problem:<\/strong> Every request to your site, every error, every system event gets written to a file. If your site is under attack or has a major PHP error, these logs can grow by gigabytes per hour.<\/li>\n\n\n\n<li><strong>Solution:<\/strong> Check this directory first. You are generally safe to delete <em>rotated<\/em> log files, which end in .1 or .gz (e.g., access.log.1, error.log.gz). For a live, active log file, you should truncate it (see next section). The long-term solution is configuring logrotate to automatically compress and delete old logs.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>WordPress and CMS-Specific Issues<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Location:<\/strong> \/var\/www\/html\/ (or your webroot)<\/li>\n\n\n\n<li><strong>Problem 1: Backups.<\/strong> Backup plugins that store the backups <em>on the same server<\/em> are a ticking time bomb. If you have 10 old backups, you are storing 10 copies of your site.\n<ul class=\"wp-block-list\">\n<li><strong>Solution:<\/strong> Check \/wp-content\/updraft\/ or similar plugin-specific folders. Delete old backups and configure your plugin to <em>only<\/em> store backups externally.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Problem 2: Caching.<\/strong> Caching plugins like W3 Total Cache can generate hundreds of thousands of files.\n<ul class=\"wp-block-list\">\n<li><strong>Solution:<\/strong> Use the &#8220;Clear Cache&#8221; button in your <a class=\"wpil_keyword_link\" href=\"https:\/\/elementor.com\/blog\/wordpress-login-url\/\"   title=\"WordPress admin\" data-wpil-keyword-link=\"linked\"  data-wpil-monitor-id=\"16270\">WordPress admin<\/a>. If that doesn&#8217;t work, you can rm -rf \/wp-content\/cache\/ (be careful!). This is also a common source of inode exhaustion.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Problem 3: Media.<\/strong> Unoptimized PNGs, full-resolution JPEGs, and old video files.\n<ul class=\"wp-block-list\">\n<li><strong>Solution:<\/strong> Optimize your images. Check your wp-content\/uploads\/ directory with du -sh * to see which year\/month folders are the largest.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>User Home Directories (<\/strong><strong>\/home<\/strong><strong>)<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Location:<\/strong> \/home\/<\/li>\n\n\n\n<li><strong>Problem:<\/strong> If you or other users have accounts, their personal files (old site backups, large .zip files, desktop Downloads) live here.<\/li>\n\n\n\n<li><strong>Solution:<\/strong> Run du -sh \/home\/* to see which user is taking up the most space and investigate their directory.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Temporary Files (<\/strong><strong>\/tmp<\/strong><strong> and <\/strong><strong>\/var\/tmp<\/strong><strong>)<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Location:<\/strong> \/tmp or \/var\/tmp<\/li>\n\n\n\n<li><strong>Problem:<\/strong> Aborted processes, file uploads, or session files can leave junk here.<\/li>\n\n\n\n<li><strong>Solution:<\/strong> It&#8217;s <em>usually<\/em> safe to delete files here, especially if they are very old. find \/tmp -type f -mtime +7 -exec rm {} \\; (delete files older than 7 days) is a common cleanup command.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Package Caches<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Location:<\/strong> Varies, but accessible via a command.<\/li>\n\n\n\n<li><strong>Problem:<\/strong> Your system&#8217;s package manager (apt or yum) keeps a cache of all the packages you&#8217;ve downloaded and installed. This can grow to several gigabytes.<\/li>\n\n\n\n<li><strong>Solution:<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>Debian\/Ubuntu:<\/strong> sudo apt-get clean<\/li>\n\n\n\n<li><strong>RHEL\/CentOS:<\/strong> sudo yum clean all This is a safe and easy way to free up 1-2GB of space.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What to Do When You Find a Large File<\/strong><\/h2>\n\n\n\n<p>You&#8217;ve used du and find and located a 30GB file: \/var\/log\/nginx\/access.log. What now?<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>To Delete or Not to Delete?<\/strong><\/h3>\n\n\n\n<p><strong>Be careful.<\/strong> Deleting the wrong file (like a database file from \/var\/lib\/mysql) will destroy your website.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Safe to delete:<\/strong> Old log files (.log.1, .log.gz), old backups (.zip, .tar.gz), files in a cache directory (\/wp-content\/cache\/), files in \/tmp.<\/li>\n\n\n\n<li><strong>NOT safe to delete:<\/strong> Active database files, core system libraries, or any file you don&#8217;t recognize.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Safely Emptying a Live Log File<\/strong><\/h3>\n\n\n\n<p><strong>Do not run <\/strong><strong>rm \/var\/log\/nginx\/access.log<\/strong><strong>!<\/strong><\/p>\n\n\n\n<p>If a service is actively writing to a file, just deleting it with rm won&#8217;t free the disk space. The service holds an open &#8220;file handle,&#8221; and Linux won&#8217;t release the space until that service is restarted.<\/p>\n\n\n\n<p>The <strong>correct<\/strong> way to empty a live log file is to truncate it.<\/p>\n\n\n\n<p><strong>Command:<\/strong> truncate -s 0 \/var\/log\/nginx\/access.log<\/p>\n\n\n\n<p>This command instantly sets the file&#8217;s size to 0 bytes <em>without<\/em> deleting it. The service keeps its file handle and just starts writing to the new, empty file. The 30GB of space will be freed immediately.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Archiving and Compressing<\/strong><\/h3>\n\n\n\n<p>If you find 10GB of old project files in \/home\/user\/old-project\/ that you don&#8217;t want to delete, you can compress them. <strong>Command:<\/strong> tar -czvf old-project.tar.gz \/home\/user\/old-project\/<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>This will create a single compressed file old-project.tar.gz.<\/li>\n\n\n\n<li>A 10GB directory of text and code files can easily compress down to &lt; 1GB.<\/li>\n\n\n\n<li>You can then safely delete the original directory: rm -rf \/home\/user\/old-project\/.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Proactive Monitoring and Automation<\/strong><\/h2>\n\n\n\n<p>You shouldn&#8217;t wait until your site is down to check your disk space.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Setting Up a Simple Bash Script<\/strong><\/h3>\n\n\n\n<p>You can create a simple script that emails you when a disk gets too full.<\/p>\n\n\n\n<p>Create a file named check_disk.sh:<\/p>\n\n\n\n<p>#!\/bin\/bash<\/p>\n\n\n\n<p>THRESHOLD=90<\/p>\n\n\n\n<p>EMAIL=&#8221;your-email@example.com&#8221;<\/p>\n\n\n\n<p>df -h | grep \/dev\/sda1 | awk &#8216;{ print $5 }&#8217; | while read -r usage; do<\/p>\n\n\n\n<p>&nbsp;&nbsp;PERCENT=$(echo $usage | sed &#8216;s\/%\/\/g&#8217;)<\/p>\n\n\n\n<p>&nbsp;&nbsp;if [ $PERCENT -gt $THRESHOLD ]; then<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;echo &#8220;Disk \/dev\/sda1 is at $usage! Host: $(hostname)&#8221; | mail -s &#8220;Disk Space Alert!&#8221; $EMAIL<\/p>\n\n\n\n<p>&nbsp;&nbsp;fi<\/p>\n\n\n\n<p>done<\/p>\n\n\n\n<p>You can set this script to run every hour using a <strong>cron job<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Using Monitoring Tools<\/strong><\/h3>\n\n\n\n<p>For any professional or business-critical site, you should use a real monitoring service. Tools like <strong>Nagios<\/strong>, <strong>Zabbix<\/strong>, or cloud-based services like <strong>Datadog<\/strong> and <strong>New Relic<\/strong> can be configured to monitor disk space, inodes, CPU, and RAM, and send you alerts <em>before<\/em> it becomes a crisis.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion: Taking Control of Your Server<\/strong><\/h2>\n\n\n\n<p>Your server is not a magical black box. It&#8217;s a system, and like any system, it needs to be monitored. By mastering these four simple commands\u2014df, du, ncdu, and find\u2014you&#8217;ve moved from being a simple &#8220;website builder&#8221; to a true &#8220;web professional.&#8221;<\/p>\n\n\n\n<p>You now have the skills to diagnose and solve one of the most common and critical server problems. You can stop guessing, pinpoint the exact source of the issue, and fix it with confidence. This is what separates the amateurs from the experts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Frequently Asked Questions (FAQ)<\/strong><\/h2>\n\n\n\n<p><strong>1. What&#8217;s the quickest way to see my overall disk usage?<\/strong> Use df -h. It gives you a human-readable summary of all mounted partitions, their total size, used space, and use percentage.<\/p>\n\n\n\n<p><strong>2. <\/strong><strong>df<\/strong><strong> and <\/strong><strong>du<\/strong><strong> show different sizes for the same directory. Why?<\/strong> df (disk free) reports on the filesystem as a whole. It shows how many blocks are <em>allocated<\/em> by the filesystem. du (disk usage) walks through and sums up the <em>actual size<\/em> of each individual file. They are measuring two different things and will almost never match perfectly. Trust df for the overall partition health and du for finding what&#8217;s <em>inside<\/em> a directory.<\/p>\n\n\n\n<p><strong>3. I deleted a huge file, but <\/strong><strong>df -h<\/strong><strong> still shows the disk is full. What&#8217;s wrong?<\/strong> A service is still holding that file open. You deleted the file&#8217;s <em>name<\/em> from the directory, but the data won&#8217;t be freed until the program writing to it (e.g., Nginx, MySQL) is restarted. You can use lsof | grep deleted to find the process. The <em>correct<\/em> way to free space from a live log file is to truncate it: truncate -s 0 \/path\/to\/file.log.<\/p>\n\n\n\n<p><strong>4. What&#8217;s an inode, and why should I care?<\/strong> An inode is an &#8220;index card&#8221; for a file. Every file and directory on your disk needs one. You can run out of these &#8220;index cards&#8221; (from millions of tiny cache or session files) even if you still have gigabytes of &#8220;shelf space&#8221; free. Use df -i to check your inode usage.<\/p>\n\n\n\n<p><strong>5. How can I find the 10 largest files or directories?<\/strong> The easiest way is to use ncdu. But with du and sort, you can do this: du -h \/home &#8211;max-depth=1 | sort -hr | head -n 10. This will show the top 10 largest directories in \/home.<\/p>\n\n\n\n<p><strong>6. Is it safe to delete files in <\/strong><strong>\/tmp<\/strong><strong>?<\/strong> Generally, yes, especially if they are old. \/tmp is a temporary directory. A safe command is find \/tmp -type f -mtime +7 -exec rm {} \\;, which deletes files older than 7 days.<\/p>\n\n\n\n<p><strong>7. What&#8217;s the difference between <\/strong><strong>df -h<\/strong><strong> and <\/strong><strong>df -H<\/strong><strong>?<\/strong> df -h (human-readable) uses powers of 1024 (binary), so 1K = 1024 bytes, 1M = 1024K. df -H (metric) uses powers of 1000, so 1K = 1000 bytes, 1M = 1000K. This is why df -h might show 49G while df -H shows 53G for the same disk. Use whichever is more comfortable for you.<\/p>\n\n\n\n<p><strong>8. My <\/strong><strong>\/var<\/strong><strong> partition is full. What&#8217;s the most likely cause?<\/strong> Almost certainly log files or database files. Use du -h &#8211;max-depth=1 \/var | sort -hr to check. The problem will likely be in \/var\/log, \/var\/lib\/mysql, or \/var\/cache.<\/p>\n\n\n\n<p><strong>9. What is <\/strong><strong>ncdu<\/strong><strong> and how is it different from <\/strong><strong>du<\/strong><strong>?<\/strong> du is a simple command-line tool that just outputs text. ncdu is an <em>interactive<\/em> tool that scans the disk and then provides a navigable interface. It&#8217;s much easier to use for &#8220;drilling down&#8221; into directories to find large files.<\/p>\n\n\n\n<p><strong>10. How can I clear my <\/strong><strong>apt<\/strong><strong> cache to free up space?<\/strong> If you are on a Debian-based system (like Ubuntu), run sudo apt-get clean. This is a very safe and easy way to free up space (sometimes gigabytes) used to cache downloaded packages. For RHEL\/CentOS, use sudo yum clean all.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As a professional focused on building and managing websites, you know that your server&#8217;s health is your site&#8217;s health. We spend a lot of time perfecting the front-end, optimizing assets, and crafting the user experience. But if the server underneath it all fails, none of that matters. One of the most common and disastrous problems I&#8217;ve seen in my career is a server silently running out of disk space.<\/p>\n","protected":false},"author":2024234,"featured_media":140946,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[512],"tags":[],"marketing_persona":[],"marketing_intent":[],"class_list":["post-141830","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-resources"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>The Ultimate Guide: How to Check Disk Space Usage in Linux<\/title>\n<meta name=\"description\" content=\"As a professional focused on building and managing websites, you know that your server&#039;s health is your site&#039;s health. We spend a lot of time perfecting the front-end, optimizing assets, and crafting the user experience. But if the server underneath it all fails, none of that matters. One of the most common and disastrous problems I&#039;ve seen in my career is a server silently running out of disk space.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The Ultimate Guide: How to Check Disk Space Usage in Linux\" \/>\n<meta property=\"og:description\" content=\"As a professional focused on building and managing websites, you know that your server&#039;s health is your site&#039;s health. We spend a lot of time perfecting the front-end, optimizing assets, and crafting the user experience. But if the server underneath it all fails, none of that matters. One of the most common and disastrous problems I&#039;ve seen in my career is a server silently running out of disk space.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/elemntor\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-10-29T03:58:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-10-29T03:58:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/elementor.com\/blog\/wp-content\/uploads\/2025\/09\/imgi_15_elementor-1-11.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Itamar Haim\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@elemntor\" \/>\n<meta name=\"twitter:site\" content=\"@elemntor\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Itamar Haim\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"21 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/\"},\"author\":{\"name\":\"Itamar Haim\",\"@id\":\"https:\/\/elementor.com\/blog\/#\/schema\/person\/5d24783541c454816685653dfed73377\"},\"headline\":\"The Ultimate Guide: How to Check Disk Space Usage in Linux\",\"datePublished\":\"2025-10-29T03:58:40+00:00\",\"dateModified\":\"2025-10-29T03:58:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/\"},\"wordCount\":4797,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/elementor.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/elementor.com\/blog\/wp-content\/uploads\/2025\/09\/imgi_15_elementor-1-11.jpeg\",\"articleSection\":[\"Resources\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/\",\"url\":\"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/\",\"name\":\"The Ultimate Guide: How to Check Disk Space Usage in Linux\",\"isPartOf\":{\"@id\":\"https:\/\/elementor.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/elementor.com\/blog\/wp-content\/uploads\/2025\/09\/imgi_15_elementor-1-11.jpeg\",\"datePublished\":\"2025-10-29T03:58:40+00:00\",\"dateModified\":\"2025-10-29T03:58:50+00:00\",\"description\":\"As a professional focused on building and managing websites, you know that your server's health is your site's health. We spend a lot of time perfecting the front-end, optimizing assets, and crafting the user experience. But if the server underneath it all fails, none of that matters. One of the most common and disastrous problems I've seen in my career is a server silently running out of disk space.\",\"breadcrumb\":{\"@id\":\"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/#primaryimage\",\"url\":\"https:\/\/elementor.com\/blog\/wp-content\/uploads\/2025\/09\/imgi_15_elementor-1-11.jpeg\",\"contentUrl\":\"https:\/\/elementor.com\/blog\/wp-content\/uploads\/2025\/09\/imgi_15_elementor-1-11.jpeg\",\"width\":1200,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/elementor.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Resources\",\"item\":\"https:\/\/elementor.com\/blog\/category\/resources\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"The Ultimate Guide: How to Check Disk Space Usage in Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/elementor.com\/blog\/#website\",\"url\":\"https:\/\/elementor.com\/blog\/\",\"name\":\"Elementor\",\"description\":\"Website Builder for WordPress\",\"publisher\":{\"@id\":\"https:\/\/elementor.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/elementor.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/elementor.com\/blog\/#organization\",\"name\":\"Elementor\",\"url\":\"https:\/\/elementor.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/elementor.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/elementor.com\/blog\/wp-content\/uploads\/2025\/06\/images.png\",\"contentUrl\":\"https:\/\/elementor.com\/blog\/wp-content\/uploads\/2025\/06\/images.png\",\"width\":225,\"height\":225,\"caption\":\"Elementor\"},\"image\":{\"@id\":\"https:\/\/elementor.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/elemntor\/\",\"https:\/\/x.com\/elemntor\",\"https:\/\/www.instagram.com\/elementor\/\",\"https:\/\/www.youtube.com\/channel\/UCt9kG_EDX8zwGSC1-ycJJVA?sub_confirmation=1\",\"https:\/\/en.wikipedia.org\/wiki\/Elementor\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/elementor.com\/blog\/#\/schema\/person\/5d24783541c454816685653dfed73377\",\"name\":\"Itamar Haim\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/elementor.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/830174068538633c83fd732c583ea1fe9d4c813314075640bf78d5a621982848?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/830174068538633c83fd732c583ea1fe9d4c813314075640bf78d5a621982848?s=96&d=mm&r=g\",\"caption\":\"Itamar Haim\"},\"description\":\"Itamar Haim, SEO Team Lead at Elementor, is a digital strategist merging SEO &amp; AEO \/ GEO, and web development. He leverages deep WordPress expertise to drive global organic growth, empowering businesses to navigate the AI era and ensuring top-tier search performance for millions of websites.\",\"sameAs\":[\"https:\/\/elementor.com\/blog\/author\/itamarha\/\",\"https:\/\/www.linkedin.com\/in\/itamar-haim-8149b85b\/\"],\"url\":\"https:\/\/elementor.com\/blog\/author\/itamarha\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The Ultimate Guide: How to Check Disk Space Usage in Linux","description":"As a professional focused on building and managing websites, you know that your server's health is your site's health. We spend a lot of time perfecting the front-end, optimizing assets, and crafting the user experience. But if the server underneath it all fails, none of that matters. One of the most common and disastrous problems I've seen in my career is a server silently running out of disk space.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/","og_locale":"en_US","og_type":"article","og_title":"The Ultimate Guide: How to Check Disk Space Usage in Linux","og_description":"As a professional focused on building and managing websites, you know that your server's health is your site's health. We spend a lot of time perfecting the front-end, optimizing assets, and crafting the user experience. But if the server underneath it all fails, none of that matters. One of the most common and disastrous problems I've seen in my career is a server silently running out of disk space.","og_url":"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/","og_site_name":"Blog","article_publisher":"https:\/\/www.facebook.com\/elemntor\/","article_published_time":"2025-10-29T03:58:40+00:00","article_modified_time":"2025-10-29T03:58:50+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/elementor.com\/blog\/wp-content\/uploads\/2025\/09\/imgi_15_elementor-1-11.jpeg","type":"image\/jpeg"}],"author":"Itamar Haim","twitter_card":"summary_large_image","twitter_creator":"@elemntor","twitter_site":"@elemntor","twitter_misc":{"Written by":"Itamar Haim","Est. reading time":"21 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/#article","isPartOf":{"@id":"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/"},"author":{"name":"Itamar Haim","@id":"https:\/\/elementor.com\/blog\/#\/schema\/person\/5d24783541c454816685653dfed73377"},"headline":"The Ultimate Guide: How to Check Disk Space Usage in Linux","datePublished":"2025-10-29T03:58:40+00:00","dateModified":"2025-10-29T03:58:50+00:00","mainEntityOfPage":{"@id":"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/"},"wordCount":4797,"commentCount":0,"publisher":{"@id":"https:\/\/elementor.com\/blog\/#organization"},"image":{"@id":"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/elementor.com\/blog\/wp-content\/uploads\/2025\/09\/imgi_15_elementor-1-11.jpeg","articleSection":["Resources"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/","url":"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/","name":"The Ultimate Guide: How to Check Disk Space Usage in Linux","isPartOf":{"@id":"https:\/\/elementor.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/#primaryimage"},"image":{"@id":"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/elementor.com\/blog\/wp-content\/uploads\/2025\/09\/imgi_15_elementor-1-11.jpeg","datePublished":"2025-10-29T03:58:40+00:00","dateModified":"2025-10-29T03:58:50+00:00","description":"As a professional focused on building and managing websites, you know that your server's health is your site's health. We spend a lot of time perfecting the front-end, optimizing assets, and crafting the user experience. But if the server underneath it all fails, none of that matters. One of the most common and disastrous problems I've seen in my career is a server silently running out of disk space.","breadcrumb":{"@id":"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/#primaryimage","url":"https:\/\/elementor.com\/blog\/wp-content\/uploads\/2025\/09\/imgi_15_elementor-1-11.jpeg","contentUrl":"https:\/\/elementor.com\/blog\/wp-content\/uploads\/2025\/09\/imgi_15_elementor-1-11.jpeg","width":1200,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/elementor.com\/blog\/how-to-check-disk-space-usage-in-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/elementor.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Resources","item":"https:\/\/elementor.com\/blog\/category\/resources\/"},{"@type":"ListItem","position":3,"name":"The Ultimate Guide: How to Check Disk Space Usage in Linux"}]},{"@type":"WebSite","@id":"https:\/\/elementor.com\/blog\/#website","url":"https:\/\/elementor.com\/blog\/","name":"Elementor","description":"Website Builder for WordPress","publisher":{"@id":"https:\/\/elementor.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/elementor.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/elementor.com\/blog\/#organization","name":"Elementor","url":"https:\/\/elementor.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/elementor.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/elementor.com\/blog\/wp-content\/uploads\/2025\/06\/images.png","contentUrl":"https:\/\/elementor.com\/blog\/wp-content\/uploads\/2025\/06\/images.png","width":225,"height":225,"caption":"Elementor"},"image":{"@id":"https:\/\/elementor.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/elemntor\/","https:\/\/x.com\/elemntor","https:\/\/www.instagram.com\/elementor\/","https:\/\/www.youtube.com\/channel\/UCt9kG_EDX8zwGSC1-ycJJVA?sub_confirmation=1","https:\/\/en.wikipedia.org\/wiki\/Elementor"]},{"@type":"Person","@id":"https:\/\/elementor.com\/blog\/#\/schema\/person\/5d24783541c454816685653dfed73377","name":"Itamar Haim","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/elementor.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/830174068538633c83fd732c583ea1fe9d4c813314075640bf78d5a621982848?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/830174068538633c83fd732c583ea1fe9d4c813314075640bf78d5a621982848?s=96&d=mm&r=g","caption":"Itamar Haim"},"description":"Itamar Haim, SEO Team Lead at Elementor, is a digital strategist merging SEO &amp; AEO \/ GEO, and web development. He leverages deep WordPress expertise to drive global organic growth, empowering businesses to navigate the AI era and ensuring top-tier search performance for millions of websites.","sameAs":["https:\/\/elementor.com\/blog\/author\/itamarha\/","https:\/\/www.linkedin.com\/in\/itamar-haim-8149b85b\/"],"url":"https:\/\/elementor.com\/blog\/author\/itamarha\/"}]}},"_links":{"self":[{"href":"https:\/\/elementor.com\/blog\/wp-json\/wp\/v2\/posts\/141830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elementor.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elementor.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elementor.com\/blog\/wp-json\/wp\/v2\/users\/2024234"}],"replies":[{"embeddable":true,"href":"https:\/\/elementor.com\/blog\/wp-json\/wp\/v2\/comments?post=141830"}],"version-history":[{"count":2,"href":"https:\/\/elementor.com\/blog\/wp-json\/wp\/v2\/posts\/141830\/revisions"}],"predecessor-version":[{"id":141832,"href":"https:\/\/elementor.com\/blog\/wp-json\/wp\/v2\/posts\/141830\/revisions\/141832"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/elementor.com\/blog\/wp-json\/wp\/v2\/media\/140946"}],"wp:attachment":[{"href":"https:\/\/elementor.com\/blog\/wp-json\/wp\/v2\/media?parent=141830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elementor.com\/blog\/wp-json\/wp\/v2\/categories?post=141830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elementor.com\/blog\/wp-json\/wp\/v2\/tags?post=141830"},{"taxonomy":"marketing_persona","embeddable":true,"href":"https:\/\/elementor.com\/blog\/wp-json\/wp\/v2\/marketing_persona?post=141830"},{"taxonomy":"marketing_intent","embeddable":true,"href":"https:\/\/elementor.com\/blog\/wp-json\/wp\/v2\/marketing_intent?post=141830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}