{"id":125,"date":"2024-01-07T13:36:36","date_gmt":"2024-01-07T13:36:36","guid":{"rendered":"https:\/\/resellerjungle.com\/articles\/?p=125"},"modified":"2024-01-07T14:49:17","modified_gmt":"2024-01-07T14:49:17","slug":"ultimate-disk-usage-commands-in-linux","status":"publish","type":"post","link":"https:\/\/resellerjungle.com\/articles\/ultimate-disk-usage-commands-in-linux\/","title":{"rendered":"Basic disk usage commands in linux"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Disk usage in <a href=\"https:\/\/resellerjungle.com\/#\" data-type=\"link\" data-id=\"https:\/\/resellerjungle.com\/\">Linux <\/a>refers to the amount of space utilized and available on a disk or file system. Monitoring disk usage is crucial for managing storage resources effectively, understanding how much space is being consumed by files, directories, and the overall system.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Linux provides various commands and utilities to assess disk usage:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"920\" height=\"460\" src=\"https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/img.png\" alt=\"\" class=\"wp-image-137\" srcset=\"https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/img.png 920w, https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/img-300x150.png 300w, https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/img-768x384.png 768w\" sizes=\"auto, (max-width: 920px) 100vw, 920px\" \/><\/figure>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#df-command\">df command: <\/a><\/li><li><a href=\"#du-disk-usage-command\">du (disk usage) command: <\/a><\/li><li><a href=\"#du-sh-command\">du -sh command: <\/a><\/li><li><a href=\"#find-command\">find command: <\/a><\/li><li><a href=\"#ls-command\">ls command: <\/a><\/li><li><a href=\"#diskutil-command\">diskutil command: <\/a><\/li><li><a href=\"#stat-command\">stat command: <\/a><\/li><li><a href=\"#fdisk-command\">fdisk command: <\/a><\/li><li><a href=\"#parted-command\">parted command: <\/a><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"df-command\"><strong>df command<\/strong>: <\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong><code>df<\/code> <\/strong>command in Linux stands for &#8220;Disk Free.&#8221; It is used to display information about the disk space usage on file systems. This command shows details such as the total amount of disk space, the amount of space used, available space, filesystem types, and their respective mount points.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When you run <code>df<\/code> without any arguments, it lists information about all mounted filesystems<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Displays information about disk space usage of file systems. It shows the amount of disk space used and available on mounted file systems.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>df -h<\/code><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"209\" src=\"https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/1-1024x209.png\" alt=\"\" class=\"wp-image-147\" srcset=\"https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/1-1024x209.png 1024w, https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/1-300x61.png 300w, https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/1-768x157.png 768w, https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/1.png 1199w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"du-disk-usage-command\"><strong>du<\/strong> (disk usage) command: <\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong><code>du<\/code> <\/strong>command in Linux stands for &#8220;Disk Usage.&#8221; It is used to estimate and display the disk space used by files and directories. This command helps users and system administrators identify the disk space consumption of specific directories or files.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By default, when you use <code>du<\/code> without any additional options, it provides the disk usage of the current directory and its subdirectories<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Estimates file and directory space usage. It shows the sizes of directories and files.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>du -h \/path\/to\/directory<\/code><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>du -h \/home\/resellerjungle<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"52\" src=\"https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/2-1-1024x52.png\" alt=\"\" class=\"wp-image-151\" srcset=\"https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/2-1-1024x52.png 1024w, https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/2-1-300x15.png 300w, https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/2-1-768x39.png 768w, https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/2-1.png 1224w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>ncdu command: <\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong><code>ncdu<\/code> <\/strong>command in Linux stands for &#8220;NCurses Disk Usage.&#8221; It&#8217;s a disk usage analyzer tool that provides a more interactive and intuitive way to visualize and manage disk space usage within the terminal.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Unlike traditional commands like <code>du<\/code> that display disk usage information in a static text format, <code>ncdu<\/code> presents a visual representation of disk usage using an interactive, text-based user interface (NCurses).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">NCurses Disk Usage is a command-line utility to interactively view and manage disk usage. It provides a top-like interface to navigate through directories and their sizes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>du \/path\/to\/directory<\/code><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>du \/home\/resellerjungle<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"51\" src=\"https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/3-1024x51.png\" alt=\"\" class=\"wp-image-153\" srcset=\"https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/3-1024x51.png 1024w, https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/3-300x15.png 300w, https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/3-768x38.png 768w, https:\/\/resellerjungle.com\/articles\/wp-content\/uploads\/2024\/01\/3.png 1284w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"du-sh-command\"><strong>du -sh command: <\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code><strong>du -sh<\/strong><\/code> command in Linux is used to summarize the total disk usage of a specific directory or file in a human-readable format.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Summarizes the total disk usage of a particular directory in a human-readable format.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>du -sh \/path\/to\/directory<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"find-command\"><strong>find command: <\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code><strong>find<\/strong><\/code> command in Linux is a powerful utility used for searching and locating files and directories within a specified directory hierarchy. It allows users to search for files based on various criteria such as filename, size, modification date, ownership, and permissions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Helps find files and directories based on various criteria such as size.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>find \/path\/to\/directory -type f -size +100M<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ls-command\"><strong>ls command: <\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong><code>ls<\/code> <\/strong>command in Linux is used to list the contents of a directory. It shows the files and directories within the specified directory, providing details such as file permissions, ownership, size, and modification time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Although primarily used for listing files, the <code>-l<\/code> option with <code>ls<\/code> can show file sizes, ownership, permissions, and timestamps.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>ls -l \/path\/to\/file<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"diskutil-command\"><strong>diskutil command: <\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong><code>diskutil<\/code> <\/strong>command is a command-line utility available on macOS systems. It is used for managing disks, volumes, partitions, and related storage devices. <code>diskutil<\/code> provides various functionalities for disk management, including formatting, partitioning, repairing disks, mounting\/unmounting volumes, and more.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">On macOS systems, diskutil is a command-line utility for querying and manipulating local disks and volumes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>diskutil list<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"stat-command\"><strong>stat command: <\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong><code>stat<\/code> <\/strong>command in Linux and Unix systems is used to display detailed information about files, including file status, metadata, and file system information. It provides various details about a file such as access permissions, inode number, file type, size, timestamps (last access, modification, and change times), and more.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Retrieves detailed file or file system status.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>stat \/path\/to\/file<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"fdisk-command\"><strong>fdisk command: <\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong><code>fdisk<\/code> <\/strong>command in Linux and Unix-based systems is a command-line utility used for disk partitioning. It allows users to create, delete, modify, and display information about partitions on a hard disk. <code>fdisk<\/code> is a powerful tool but requires careful usage as it deals with disk partitions and can potentially lead to data loss if not used correctly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A command-line utility for disk partitioning. It&#8217;s used to view, create, delete, change, or resize partitions on a hard drive.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>do fdisk -l<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"parted-command\"><strong>parted command: <\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The <code><strong>parted<\/strong><\/code> command in Linux is a powerful command-line utility used for disk partitioning and managing disk partitions. It is a versatile tool that allows users to create, delete, resize, move, and manipulate disk partitions on hard drives. <code>parted<\/code> is especially useful for working with modern disk formats like GUID Partition Table (GPT) and is more flexible compared to older utilities like <code>fdisk<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Another command for partition manipulation, providing functionalities similar to fdisk but with a different interface.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>sudo parted \/dev\/sdX print<\/code><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Remember to use these commands carefully, especially when dealing with system-level operations like disk partitioning, to avoid data loss or accidental modifications. Use <code>man<\/code> followed by the command name for more detailed information and available options.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Disk usage in Linux refers to the amount of space utilized and available on a disk or file system. Monitoring&hellip;<\/p>\n","protected":false},"author":2,"featured_media":141,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[15],"class_list":["post-125","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-disk-usage"],"_links":{"self":[{"href":"https:\/\/resellerjungle.com\/articles\/wp-json\/wp\/v2\/posts\/125","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/resellerjungle.com\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/resellerjungle.com\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/resellerjungle.com\/articles\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/resellerjungle.com\/articles\/wp-json\/wp\/v2\/comments?post=125"}],"version-history":[{"count":17,"href":"https:\/\/resellerjungle.com\/articles\/wp-json\/wp\/v2\/posts\/125\/revisions"}],"predecessor-version":[{"id":154,"href":"https:\/\/resellerjungle.com\/articles\/wp-json\/wp\/v2\/posts\/125\/revisions\/154"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/resellerjungle.com\/articles\/wp-json\/wp\/v2\/media\/141"}],"wp:attachment":[{"href":"https:\/\/resellerjungle.com\/articles\/wp-json\/wp\/v2\/media?parent=125"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/resellerjungle.com\/articles\/wp-json\/wp\/v2\/categories?post=125"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/resellerjungle.com\/articles\/wp-json\/wp\/v2\/tags?post=125"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}