{"id":36,"date":"2023-09-21T13:31:42","date_gmt":"2023-09-21T12:31:42","guid":{"rendered":"https:\/\/thevadasan.com\/?p=36"},"modified":"2024-04-29T13:29:24","modified_gmt":"2024-04-29T12:29:24","slug":"how-to-get-summary-of-disk-usage-using-ncdu","status":"publish","type":"post","link":"https:\/\/thevadasan.com\/?p=36","title":{"rendered":"How to get a summary of disk usage using ncdu"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<p><strong>What is Ncdu?<\/strong><\/p>\n\n\n\n<p><code>Ncdu<\/code> (NCurses Disk Usage) is a command-line based disk usage analyzer. The tool provides a fast and efficient way to find out which files and directories consume the most space on your disk. By using ncdu, you can get a clear overview of disk usage, making it easier to determine which files or directories need to be cleaned up to free space.<\/p>\n\n\n\n<p><strong>How to Install Ncdu<\/strong><\/p>\n\n\n\n<p>Before diving into how to use ncdu, you&#8217;ll need to have it installed on your system.<\/p>\n\n\n\n<p>On most Linux distributions, you can use the native package manager:<\/p>\n\n\n\n<ul>\n<li>Ubuntu\/Debian: <code>sudo apt-get install ncdu<\/code><\/li>\n\n\n\n<li>CentOS\/Red Hat: <code>sudo yum install ncdu<\/code><\/li>\n\n\n\n<li>Fedora: <code>sudo dnf install ncdu<\/code><\/li>\n\n\n\n<li>Arch Linux: <code>sudo pacman -S ncdu<\/code><\/li>\n<\/ul>\n\n\n\n<p><strong>How to Use Ncdu<\/strong><\/p>\n\n\n\n<p>Using ncdu is straightforward. After installation, navigate to the directory you want to scan and type <code>ncdu<\/code> in the terminal.<\/p>\n\n\n\n<p>For example, to analyze the home directory:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ncd ~\nncdu\n<\/pre><\/div>\n\n\n<p>Ncdu will scan the directory and display the results in a hierarchical, easy-to-read manner. You&#8217;ll see directories listed in descending order based on their size, with the largest directories listed first.<\/p>\n\n\n\n<p>Key commands within ncdu:<\/p>\n\n\n\n<ul>\n<li><code>\u2191<\/code> and <code>\u2193<\/code> arrows: Navigate the list.<\/li>\n\n\n\n<li><code>Enter<\/code>: Dive into a directory.<\/li>\n\n\n\n<li><code>\u2190<\/code>: Go back to the parent directory.<\/li>\n\n\n\n<li><code>d<\/code>: Delete the selected file or directory (be cautious with this command).<\/li>\n\n\n\n<li><code>n<\/code>: Sort by name (default is by size).<\/li>\n\n\n\n<li><code>s<\/code>: Toggle between showing size and items.<\/li>\n\n\n\n<li><code>g<\/code>: Toggle between showing items and apparent size.<\/li>\n\n\n\n<li><code>q<\/code>: Quit ncdu.<\/li>\n<\/ul>\n\n\n\n<p><strong>Tips and Tricks<\/strong><\/p>\n\n\n\n<ol>\n<li><strong>Analyze a Directory Without Entering It<\/strong>: You can specify the directory you want to scan as an argument. For example, <code>ncdu \/var<\/code> will scan the \/var directory.<\/li>\n\n\n\n<li><strong>Exclude Directories<\/strong>: Using the <code>-X<\/code> or <code>--exclude<\/code> option, you can exclude specific directories. For example, <code>ncdu -X Downloads<\/code> will exclude the Downloads directory.<\/li>\n\n\n\n<li><strong>Export and Import Results<\/strong>: You can export the scan results for later analysis using the <code>-o<\/code> or <code>--output-file<\/code> option. Later, you can read the results with the <code>-f<\/code> or <code>--load-from-file<\/code> option. This can be helpful when you want to compare disk usage over time.<\/li>\n\n\n\n<li><strong>Use in Remote Sessions<\/strong>: Ncdu is especially useful when connected to a remote server using SSH. Since it&#8217;s a terminal-based application, it works seamlessly in this environment, allowing you to analyze and manage disk usage on remote machines easily.<\/li>\n\n\n\n<li><strong>Limit Depth<\/strong>: If you only want to view directories up to a certain depth, use the <code>-d<\/code> or <code>--max-depth<\/code> option. For instance, <code>ncdu -d 1<\/code> will only show top-level directories.<\/li>\n<\/ol>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>Ncdu is a powerful tool for analyzing disk usage on Linux systems. Its intuitive interface, combined with its lightweight nature, makes it a favorite among sysadmins and regular users alike. By familiarizing yourself with its features and shortcuts, you can quickly and effectively manage and reclaim disk space on your system.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is Ncdu? Ncdu (NCurses Disk Usage) is a command-line based disk usage analyzer. The tool provides a fast and efficient way to find out which files and directories consume the most space on your disk. By using ncdu, you can get a clear overview of disk usage, making it easier to determine which files [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":74,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[17,18],"tags":[19],"_links":{"self":[{"href":"https:\/\/thevadasan.com\/index.php?rest_route=\/wp\/v2\/posts\/36"}],"collection":[{"href":"https:\/\/thevadasan.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thevadasan.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thevadasan.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thevadasan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=36"}],"version-history":[{"count":2,"href":"https:\/\/thevadasan.com\/index.php?rest_route=\/wp\/v2\/posts\/36\/revisions"}],"predecessor-version":[{"id":38,"href":"https:\/\/thevadasan.com\/index.php?rest_route=\/wp\/v2\/posts\/36\/revisions\/38"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/thevadasan.com\/index.php?rest_route=\/wp\/v2\/media\/74"}],"wp:attachment":[{"href":"https:\/\/thevadasan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thevadasan.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thevadasan.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}