{"id":10690,"date":"2026-05-07T20:06:54","date_gmt":"2026-05-07T20:06:54","guid":{"rendered":"https:\/\/commandlinux.com\/?p=10690"},"modified":"2026-05-07T20:06:56","modified_gmt":"2026-05-07T20:06:56","slug":"linux-check-disk-space","status":"publish","type":"post","link":"https:\/\/commandlinux.com\/qa\/linux-check-disk-space\/","title":{"rendered":"How To Check Disk Space Using Terminal Commands In Linux"},"content":{"rendered":"\n<style>\n@import url('https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@400;500;600;700&display=swap');\n.cl-article a { color: #1a56db; text-decoration: none; }\n.cl-article a:hover { text-decoration: underline; }\n.cl-article code {\n  background: #f5f5f5;\n  padding: 2px 6px;\n  border-radius: 3px;\n  font-family: 'SF Mono', Monaco, Consolas, monospace;\n  font-size: 14px;\n  color: #c7254e;\n}\n.cl-article pre {\n  background: #f8f8f8;\n  padding: 14px 16px;\n  border-radius: 4px;\n  overflow-x: auto;\n  font-family: 'SF Mono', Monaco, Consolas, monospace;\n  font-size: 14px;\n  margin: 12px 0 18px 0;\n  color: #2d2d2d;\n}\n.cl-article table {\n  width: 100%;\n  border-collapse: collapse;\n  margin: 16px 0 22px 0;\n  font-size: 15px;\n}\n.cl-article th {\n  text-align: left;\n  padding: 10px 12px;\n  background: #fafafa;\n  font-weight: 600;\n  border-bottom: 2px solid #e5e5e5;\n  color: #111;\n}\n.cl-article td {\n  padding: 10px 12px;\n  border-bottom: 1px solid #eee;\n  vertical-align: top;\n}\n.cl-article .chart-wrap {\n  margin: 22px 0 28px 0;\n  padding: 18px 6px 4px 6px;\n}\n.cl-article .chart-title {\n  font-size: 14px;\n  font-weight: 600;\n  color: #444;\n  margin-bottom: 14px;\n  text-align: center;\n}\n<\/style>\n\n<div class=\"cl-article\">\n\n<p>Storage problems hit fast on a Linux server. Apps fail, logs stop writing, and users see write errors. The terminal gives you everything needed to spot the issue before it spreads. A few commands tell you which partition is filling up, which folder caused it, and which file to clear out. Knowing how to linux check disk space saves hours of troubleshooting.<\/p>\n\n<table>\n<thead>\n<tr><th>Tool<\/th><th>What it shows<\/th><th>Best for<\/th><\/tr>\n<\/thead>\n<tbody>\n<tr><td>df<\/td><td>Free and used space on mounted filesystems<\/td><td>Partition-level overview<\/td><\/tr>\n<tr><td>du<\/td><td>Space taken by files and folders<\/td><td>Tracking down heavy directories<\/td><\/tr>\n<tr><td>ncdu<\/td><td>Interactive folder breakdown<\/td><td>Cleaning up live<\/td><\/tr>\n<tr><td>lsblk<\/td><td>Block devices and partitions tree<\/td><td>Hardware-level layout<\/td><\/tr>\n<\/tbody>\n<\/table>\n\n<h2>The df Command to Check Disk Space on Mounted Partitions<\/h2>\n\n<p>The df command reports free and used space across mounted filesystems. Running it without arguments returns 1K blocks, which is awkward to read. Add the -h flag for human-friendly units like K, M, and G.<\/p>\n\n<pre>df -h<\/pre>\n\n<p>The output has six columns: filesystem name, total size, used space, available space, use percentage, and mount point. Anything above 85% in the use column deserves attention before write errors start.<\/p>\n\n<p>Target a single mount by passing a path:<\/p>\n\n<pre>df -h \/home<\/pre>\n\n<p>Add -T to print filesystem types like ext4, xfs, or btrfs. Use &#8211;total to print a grand total row across mounts. For inode usage instead of blocks, run df -i, since a server can run out of inodes long before it runs out of bytes.<\/p>\n\n<h2>The du Command for Directory and File Sizes<\/h2>\n\n<p>While df works at the partition level, du measures specific files and folders. Its default output lists every subdirectory on its own line, which buries the useful numbers. Pair -s for a summary with -h for readable sizes.<\/p>\n\n<pre>du -sh \/var\/log<\/pre>\n\n<p>That returns one line with the total size of \/var\/log. To go one level deep, use &#8211;max-depth:<\/p>\n\n<pre>du -h --max-depth=1 \/var<\/pre>\n\n<p>This prints the size of every direct subdirectory inside \/var, letting you walk down the tree until the heavy folders show up. The <a href=\"https:\/\/commandlinux.com\/man-page\/du\/\">du reference page<\/a> documents every option, from &#8211;apparent-size to &#8211;exclude. On busy servers, append <code>2&gt;\/dev\/null<\/code> to silence permission errors that clutter the output.<\/p>\n\n<h2>Using ncdu to Linux Check Disk Space Interactively<\/h2>\n\n<p>ncdu is a terminal-based scanner that runs as a sortable, navigable list. Install it with <code>sudo apt install ncdu<\/code> on Debian-based systems or <code>sudo yum install ncdu<\/code> on Red Hat. Then point it at any path:<\/p>\n\n<pre>ncdu \/var<\/pre>\n\n<p>It builds a sorted view of folders by size. Arrow keys move you through the tree, and pressing d removes files without leaving the interface. For finding what is eating gigabytes on a crowded disk, ncdu is one of the fastest options around.<\/p>\n\n<h2>Other Useful Tools to Linux Check Disk Space<\/h2>\n\n<h3>pydf for Color-Coded Partition Views<\/h3>\n\n<p>pydf is a Python rewrite of df with colored output. Install it through your package manager and run pydf with no flags. The same data shows up, but partitions near capacity stand out in red, which makes scanning multiple mounts faster.<\/p>\n\n<h3>lsblk for Physical Disk Layout<\/h3>\n\n<p>lsblk prints a tree of every block device on the system, from physical drives down to partitions and logical volumes. The output includes mount points, giving hardware context that df alone will not show. Helpful when an unmounted disk is the missing piece.<\/p>\n\n<h3>stat for Single-File Inspection<\/h3>\n\n<p>When you need every detail on one file, run <code>stat filename<\/code>. The <a href=\"https:\/\/commandlinux.com\/man-page\/man2\/stat\/\">stat system call<\/a> returns byte size, block allocation, permissions, owner, and the three timestamps. Useful when checking suspiciously large files flagged by du.<\/p>\n\n<h3>lsof for Phantom Space<\/h3>\n\n<p>Sometimes df reports more usage than du can find. The cause is almost always a deleted file still held open by a running process. Run <code>lsof +L1<\/code> to list those files, then restart or kill the holding process to release the blocks.<\/p>\n\n<h2>Combining Commands to Linux Check Disk Space Effectively<\/h2>\n\n<p>Piping commands together gives you targeted answers. To list the ten biggest folders inside \/var:<\/p>\n\n<pre>du -h \/var | sort -rh | head -n 10<\/pre>\n\n<p>The -rh flags sort in reverse and respect human-readable sizes. To exclude a file type from the total:<\/p>\n\n<pre>du -sh --exclude='*.zip' \/home\/user<\/pre>\n\n<p>The find command pulls files past a size threshold:<\/p>\n\n<pre>find \/var\/log -type f -size +100M<\/pre>\n\n<p>That returns every regular file in \/var\/log over 100 MB. Pipe it through xargs ls -lh for full listings. Add -mtime +30 to limit results to files older than thirty days, which is handy for clearing stale archives. For richer system-level monitoring across CPU, memory, and disk together, the <a href=\"https:\/\/commandlinux.com\/man-page\/dstat\/\">dstat utility<\/a> reports everything in one stream.<\/p>\n\n<h2>FAQs<\/h2>\n\n<h3>When should I use df vs du?<\/h3>\n\n<p>df gives a partition-level view of free and used space across mounted filesystems. du measures the space inside specific folders or files. Use df for a quick health check and du to track down what is consuming the space.<\/p>\n\n<h3>Why does df report more space used than du shows?<\/h3>\n\n<p>Running processes can hold deleted files open, keeping their blocks reserved on disk. Run <code>lsof +L1<\/code> to list them. Restarting or killing the process holding the handle releases the space immediately.<\/p>\n\n<h3>How do I find the largest files on Linux?<\/h3>\n\n<p>Run <code>find \/ -type f -size +1G<\/code> for files over a gigabyte, or pipe <code>du -ah \/ | sort -rh | head -20<\/code> for the top twenty by size. ncdu handles this interactively for any chosen path.<\/p>\n\n<h3>Which directories fill up first on a Linux server?<\/h3>\n\n<p>\/var\/log holds system and application logs that grow daily. \/tmp and \/var\/tmp collect short-lived files. \/home stores user data, and \/var\/lib often hides large database files that consume entire partitions.<\/p>\n\n<h3>How can I clear a log file without deleting it?<\/h3>\n\n<p>Run <code>&gt; \/var\/log\/syslog<\/code> to truncate it to zero bytes while keeping the file handle open, so the running process keeps writing. The <a href=\"https:\/\/commandlinux.com\/man-page\/man8\/logrotate\">logrotate scheduler<\/a> automates this rotation, compression, and cleanup.<\/p>\n\n<\/div>\n\n\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>Learn how to linux check disk space with simple terminal commands that identify full partitions, large folders, and storage-hogging files. Fix disk space issues early to keep your Linux server stable and running without errors.<\/p>\n","protected":false},"author":1,"featured_media":10691,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[],"class_list":["post-10690","post","type-post","status-publish","format-standard","has-post-thumbnail","category-qa"],"_links":{"self":[{"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/posts\/10690","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/comments?post=10690"}],"version-history":[{"count":1,"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/posts\/10690\/revisions"}],"predecessor-version":[{"id":10692,"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/posts\/10690\/revisions\/10692"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/media\/10691"}],"wp:attachment":[{"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/media?parent=10690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/categories?post=10690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/commandlinux.com\/wp-json\/wp\/v2\/tags?post=10690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}