{"id":24903,"date":"2025-08-25T10:44:45","date_gmt":"2025-08-25T08:44:45","guid":{"rendered":"https:\/\/contabo.com\/blog\/?p=24903"},"modified":"2026-02-14T15:12:00","modified_gmt":"2026-02-14T14:12:00","slug":"how-to-check-disk-space-usage-in-linux","status":"publish","type":"post","link":"https:\/\/contabo.com\/blog\/how-to-check-disk-space-usage-in-linux\/","title":{"rendered":"How to Check Disk Space Usage in Linux"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"630\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2025\/08\/blog-head_how2_check_disk_space_usage_in_linux-1.jpg\" alt=\"How to Check Disk Space Usage in Linux\" class=\"wp-image-24951\" srcset=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2025\/08\/blog-head_how2_check_disk_space_usage_in_linux-1.jpg 1200w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2025\/08\/blog-head_how2_check_disk_space_usage_in_linux-1-600x315.jpg 600w, https:\/\/contabo.com\/blog\/wp-content\/uploads\/2025\/08\/blog-head_how2_check_disk_space_usage_in_linux-1-768x403.jpg 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<p>Running out of disk space on a server is a classic problem that can cause everything from application errors to a complete system crash. Proactive monitoring of your disk space usage is a critical task for maintaining a healthy, high-performing server. Understanding the state of your Linux file system helps you prevent these issues before they affect your users. <\/p>\n\n\n\n<p>When you need to <strong>check Linux disk space<\/strong>, the terminal provides a powerful set of tools to quickly identify what&#8217;s taking up room and where. This guide will walk you through the essential commands, from basic checks to advanced analysis, so you can keep your server&#8217;s storage in check.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"how-to-check-disk-space-in-linux\">How to Check Disk Space in Linux<\/h2>\n\n\n\n<p>The primary Linux command to check disk space comes in two main forms: <code>df<\/code> for a high-level view of your filesystems, and <code>du<\/code> for a detailed look at directory and file sizes. Understanding the difference is key: <code>df<\/code> (disk free) reports on the total space used and available on your mounted partitions, while <code>du<\/code> (disk usage) calculates the space consumed by specific files and directories. You&#8217;ll use <code>df<\/code> to see if a partition is getting full and <code>du<\/code> to find out what&#8217;s filling it up.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Check file space usage in Linux with the <code>df<\/code> command<\/h3>\n\n\n\n<p>The <code>df<\/code> command gives you a quick overview of all your mounted filesystems, their total size, how much space is used, and how much is available. Running it without any options produces output in 1-kilobyte blocks, which can be hard to read. Always use the <code>-h<\/code> (human-readable) flag to see sizes in gigabytes (G), megabytes (M), and kilobytes (K).<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>df -h<\/code><\/pre>\n\n\n\n<p>The output shows each filesystem, its size, the amount used and available, the percentage of space used, and where it&#8217;s mounted. This is your first stop when you suspect a disk space issue.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Check file space usage in Linux with the <code>du<\/code> command<\/h3>\n\n\n\n<p>Once <code>df<\/code> tells you a partition is nearly full, the Linux <code>du<\/code> command helps you pinpoint the culprit. By default, <code>du<\/code> shows the size of every subdirectory, which can be overwhelming. To get a summary for a specific directory, use the <code>-s<\/code> (summarize) and <code>-h<\/code> (human-readable) flags.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>du -sh \/var\/log<\/code><\/pre>\n\n\n\n<p>This command will return a single, human-readable total for the <code>\/var\/log<\/code> directory. To see the size of each subdirectory one level deep, you can use the <code>--max-depth<\/code> flag:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>du -h --max-depth=1 \/var<\/code><\/pre>\n\n\n\n<p>This helps you systematically drill down into the file system to find where space is being consumed.<\/p>\n\n\n\n<p>While <code>df<\/code> and <code>du<\/code> are the workhorses of disk space analysis, several other tools offer more advanced or user-friendly ways to get the job done.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Check disk space usage in Linux with the <code>ncdu<\/code> command<\/h3>\n\n\n\n<p>The Linux <code>ncdu<\/code> command provides an interactive, ncurses-based disk usage analyzer right in your terminal. After installing it (<code>sudo apt install ncdu<\/code> or <code>sudo yum install ncdu<\/code>), run <code>ncdu \/path\/to\/directory<\/code>. It will scan the directory and present an interactive, sorted list of files and directories by size. You can navigate with the arrow keys, drill down into subdirectories, and even delete files or directories directly from the interface. This makes <code>ncdu<\/code> one of the fastest ways to find and clean up what&#8217;s consuming your<strong> <\/strong>Linux disk space.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Check disk space usage in Linux with the <code>pydf<\/code> command<\/h3>\n\n\n\n<p>If you find the standard <code>df<\/code> output a bit plain, the Linux <code>pydf<\/code> command is a great alternative. As a Python-based script, <code>pydf<\/code> displays the same information as <code>df<\/code> but with a colorful, more readable layout that helps you quickly spot filesystems that are nearing capacity. You may need to install it first (<code>sudo apt install pydf<\/code> or <code>sudo yum install pydf<\/code>), but its clear output can make monitoring your Linux disk size a more manageable experience.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">List block devices in Linux with the <code>lsblk<\/code> command<\/h3>\n\n\n\n<p>Sometimes you need to see the underlying physical and logical disks that your filesystems are built on. The <code>lsblk<\/code> command in Linux (list block devices) provides this context. It displays a tree view of all your block devices &#8211; disks, partitions, and logical volumes &#8211; and shows how they are mounted. This is especially helpful for understanding the relationship between the devices <code>df<\/code> reports on and the actual hardware in your server.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Get detailed file information in Linux with the <code>stat<\/code> command<\/h3>\n\n\n\n<p>When you need to know everything about a single file, the <code>stat<\/code> command is your tool. Running <code>stat filename<\/code> provides detailed metadata, including the file&#8217;s exact size, its block usage on disk, permissions, and important timestamps like its last access, modification, and change times. This is perfect for deep inspection when analyzing a specific file&#8217;s properties.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ways-to-combine-commands-during-disk-space-checks\">Ways to Combine Commands During Disk Space Checks<\/h2>\n\n\n\n<p>The real power of the Linux command line comes from combining tools. By piping the output of one command into another, you can create highly specific queries to find exactly what you&#8217;re looking for.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Sort files by size<\/h3>\n\n\n\n<p>One of the most common tasks is finding the largest files or directories. You can easily sort Linux files by size<strong> <\/strong>by combining <code>du<\/code> and <code>sort<\/code>. The <code>-r<\/code> flag for <code>sort<\/code> reverses the order (to show largest first), and <code>-h<\/code> makes it understand human-readable numbers like &#8216;1G&#8217; or &#8217;10M&#8217;.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>du -h \/var | sort -rh | head -n 10<\/code><\/pre>\n\n\n\n<p>This command finds the top 10 largest directories within <code>\/var<\/code>, giving you an instant list of places to investigate.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Exclude files by type<\/h3>\n\n\n\n<p>Sometimes you want to calculate a directory&#8217;s size while ignoring certain files, like backups or archives. The <code>du<\/code> command has a handy <code>--exclude<\/code> flag for this purpose.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>du -sh --exclude='*.zip' \/home\/user\/documents<\/code><\/pre>\n\n\n\n<p>This calculates the total size of the <code>documents<\/code> directory but ignores all <code>.zip<\/code> files in its calculation.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Exclude files by size<\/h3>\n\n\n\n<p>To find files based on their size, the <code>find<\/code> command is the perfect tool. You can use it to locate all files larger (or smaller) than a specific size, which is invaluable for cleaning up large log files or old archives.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>find \/var\/log -type f -size +100M<\/code><\/pre>\n\n\n\n<p>This command will search the <code>\/var\/log<\/code> directory and list every file (<code>-type f<\/code>) that is larger than 100 megabytes (<code>-size +100M<\/code>).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"linux-disk-space-usage-management-faq\">Linux Disk Space Usage Management FAQ<\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1771078202103\"><strong class=\"schema-faq-question\"><strong>What&#8217;s the difference between <code>df<\/code> and <code>du<\/code>?<\/strong><\/strong> <p class=\"schema-faq-answer\"><code>df<\/code> (disk free) reports on filesystem-level usage, showing the total size and free space on a partition. <code>du<\/code> (disk usage) calculates the space consumed by a specific set of files or directories. Use <code>df<\/code> to see if a disk is full and <code>du<\/code> to find out what is filling it.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1771078214130\"><strong class=\"schema-faq-question\"><strong>Why does my disk usage (<code>df<\/code>) seem higher than the files I can find (<code>du<\/code>)?<\/strong><\/strong> <p class=\"schema-faq-answer\">This common issue is often caused by open file descriptors. If a program is writing to a file that has been deleted, the space is not freed until the program closes the file. <code>du<\/code> can&#8217;t see the deleted file, but <code>df<\/code> knows the space is still allocated. Use a command like <code>lsof +L1<\/code> to find processes holding onto deleted files.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1771078228210\"><strong class=\"schema-faq-question\"><strong>What are the first places to check when a disk is full?<\/strong><\/strong> <p class=\"schema-faq-answer\">Start with common culprits for runaway growth: log directories (<code>\/var\/log<\/code>), temporary file directories (<code>\/tmp<\/code> and <code>\/var\/tmp<\/code>), and user home directories (<code>\/home<\/code>).<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1771078245878\"><strong class=\"schema-faq-question\"><strong>How can I safely clean up log files?<\/strong><\/strong> <p class=\"schema-faq-answer\">Avoid simply deleting log files that are in use. The best practice is to use the <code>logrotate<\/code> utility, which handles rotation, compression, and deletion automatically. For manual cleanup, you can truncate a file to zero size without deleting it by running <code>> filename<\/code>. This frees up the space immediately, even if a process still has the file open.<\/p> <\/div> <\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>Proactive monitoring is the key to preventing storage-related outages. By regularly using tools like <code>df<\/code>, <code>du<\/code>, and the more advanced <code>ncdu<\/code>, you can stay ahead of problems and keep your server running smoothly. Learning to combine these commands with <code>sort<\/code>, <code>find<\/code>, and other filters gives you a powerful toolkit for analyzing and managing your Linux disk space efficiently.<\/p>\n\n\n\n<p>Ultimately, having a reliable platform is the foundation of a healthy server. A reliable <a href=\"https:\/\/contabo.com\/en\/linux-vps\/\" target=\"_blank\" rel=\"noreferrer noopener\">Linux VPS<\/a> gives you the solid base you need, and with these disk management skills, you&#8217;ll be well-equipped to maintain it for the long term.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Don&#8217;t let a full disk bring your server down. This guide teaches you how to check and manage disk space usage on your Linux server, covering fundamental commands like df and du, and advanced interactive tools like ncdu. Learn how to find the largest files, sort directories by size, and safely clean up your filesystem to maintain optimal performance.<\/p>\n","protected":false},"author":63,"featured_media":24907,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[18],"tags":[3101,281,3100,3102,510,3103,3104,1955,3098,1762,1647],"ppma_author":[1492],"class_list":["post-24903","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-df","tag-disk-space","tag-disk-usage","tag-du","tag-linux","tag-lsblk","tag-ncdu","tag-server-maintenance","tag-sysadmin-2","tag-system-administration","tag-troubleshooting"],"uagb_featured_image_src":{"full":["https:\/\/contabo.com\/blog\/wp-content\/uploads\/2025\/08\/blog-head_how2_check_disk_space_usage_in_linux.jpg",1200,630,false],"thumbnail":["https:\/\/contabo.com\/blog\/wp-content\/uploads\/2025\/08\/blog-head_how2_check_disk_space_usage_in_linux-150x150.jpg",150,150,true],"medium":["https:\/\/contabo.com\/blog\/wp-content\/uploads\/2025\/08\/blog-head_how2_check_disk_space_usage_in_linux-600x315.jpg",600,315,true],"medium_large":["https:\/\/contabo.com\/blog\/wp-content\/uploads\/2025\/08\/blog-head_how2_check_disk_space_usage_in_linux-768x403.jpg",768,403,true],"large":["https:\/\/contabo.com\/blog\/wp-content\/uploads\/2025\/08\/blog-head_how2_check_disk_space_usage_in_linux.jpg",1200,630,false],"1536x1536":["https:\/\/contabo.com\/blog\/wp-content\/uploads\/2025\/08\/blog-head_how2_check_disk_space_usage_in_linux.jpg",1200,630,false],"2048x2048":["https:\/\/contabo.com\/blog\/wp-content\/uploads\/2025\/08\/blog-head_how2_check_disk_space_usage_in_linux.jpg",1200,630,false]},"uagb_author_info":{"display_name":"Christopher Carter","author_link":"https:\/\/contabo.com\/blog\/author\/christophercarter\/"},"uagb_comment_info":0,"uagb_excerpt":"Don't let a full disk bring your server down. This guide teaches you how to check and manage disk space usage on your Linux server, covering fundamental commands like df and du, and advanced interactive tools like ncdu. Learn how to find the largest files, sort directories by size, and safely clean up your filesystem&hellip;","authors":[{"term_id":1492,"user_id":63,"is_guest":0,"slug":"christophercarter","display_name":"Christopher Carter","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/63db81672a5ce4c1e8ee39753d00251d561b5b3a9967febf1c4f662024cef00f?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/posts\/24903","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/comments?post=24903"}],"version-history":[{"count":7,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/posts\/24903\/revisions"}],"predecessor-version":[{"id":28273,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/posts\/24903\/revisions\/28273"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/media\/24907"}],"wp:attachment":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/media?parent=24903"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/categories?post=24903"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/tags?post=24903"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=24903"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}