How To Check Disk Space In Linux In Two Easy Methods (2024)

Many admins and users often forget about checking the available disk space because servers generally have storage space in terabytes.

However, given the current package sizes and the increasing number of software admins need to install for server management and business operations, running out of server space is a real possibility.

Checking disk space on Linux using the command line is not just an idle operation. It is now a recommended practice before you attempt to install anything new or upgrade existing packages.

In this short but comprehensive guide, we’ll show you how to check disk space on Linux systems. We’ll cover two critical methods of checking available disk space so that you can easily install software without worrying about insufficient disk space.

Table of Contents

  1. Use the Command Line to Check Disk Space in Linux
    • Prerequisites
    • Method #1: Use the df Command to Check Disk Space in Linux
    • Method #2: Use the du Command to Assess Disk Space Usage
  2. Conclusion
  3. FAQs

Use the Command Line to Check Disk Space in Linux

Before discovering the two methods of checking disk space, let’s see the prerequisites for these commands:

Prerequisites

  • A system running a mainstream Linux distro
  • An account with root or sudo privileges
  • Access to the command line or terminal

Method #1: Use the df Command to Check the Disk Space in Linux

The df command is one of the easiest ways to check disk space usage and available block size. Launch the terminal and enter the following command:

# df

How To Check Disk Space In Linux In Two Easy Methods (1)

As you can see, the df command, which stands for disk free, displays how much space each drive uses. Note that, by default, the values are shown in 1-kilobyte blocks.

The df command provides much information about disk utilization and available space.

Here’s a run-through of the information items that you can see in the command’s output:

  • Filesystem: This entry shows the real hard disk drives, logical (partitioned) drives, and temporary or virtual drives.
  • Size: The filesystem’s actual disk size.
  • Used: The storage space each file system has used.
  • Available: The size of the filesystem’s available (free) space.
  • Use%: The percentage of the disk’s space in use.
  • Mounted on: Shows the mount point for each drive (physical and virtual). This entry also includes temporary drives.

The Filesystem entry covers all attached physical and virtual devices, including processes. Here’s a brief description of the entries in this column:

  • /dev/sda: This is the hard drive on your system. If you have multiple drives (physical and virtual), they’ll be labeled sequentially as /sdb, /sdc, /sde.
  • /dev: This virtual directory is an important part of the Linux file system.
  • tmpfs: – These are transient disk filesystems for the operating system’s execution and are used by the various Linux procedures. For instance, the system creates lock files using the tmpfs /run/lock. These files stop several people from making simultaneous changes to the same file.

Let’s discuss some important flags and options you can use with the df command for more detailed and better-formatted information.

Display Disk Usage in Megabyte and Gigabyte

By default, the df command displays available disk space in KB blocks. Given the huge disk volumes, this is an unrealistic scale because we are used to measuring the disk space in MBs and GBs.

You can display disk size space output in a more understandable format by including the -h flag:

# df -h

How To Check Disk Space In Linux In Two Easy Methods (2)

Understanding the Format of the Output

Let’s take a closer look at the output, especially the columns.

  • Filesystem: This is the name of the drive. This column includes virtual or temporary drives, logical (partitioned), and hard drives.
  • Size: The filesystem’s size.
  • Used: Indicates how much space every filesystem is using at the moment.
  • Avail: The amount of free (empty) space on the filesystem.
  • Use%: Displays the disk usage percentage.
  • Mounted on: The file system type is located in this directory. Another name for this location is a mount point.

Note that the physical hard disk has been included in the list of filesystems.

How To Check Disk Space In Linux In Two Easy Methods (3)

Show a Particular File System

If you wish to inspect a single disk out of a multi-disk storage component, you can use the -h flag and file system of the target drive. This will show the output in a human-readable format.

# df -h /dev/sda

How To Check Disk Space In Linux In Two Easy Methods (4)

If you wish to view the usage details about the root partition, use the backslash as a shortcut:

# df -h /

How To Check Disk Space In Linux In Two Easy Methods (5)

Display Disk Information by File System

You can list disk information for a specific file system if you have multiple file systems on your server. For this, use the following command:

# df -ht ext4

The -h flag formats the output in a human-friendly list of drives with the ext4 file system.

How To Check Disk Space In Linux In Two Easy Methods (6)

Method #2: Use the du Command to Assess Disk Space Usage

The du command shows the use of the disk.

This utility shows disk space consumption by the size of directories, providing a more detailed overview of your disk consumption.

When used without any flag or option, the command shows how much space is being consumed by your current directory.

# du

How To Check Disk Space In Linux In Two Easy Methods (7)

Like the df command, you can format the output of du to be human-readable with the -h flag:

# du -h

How To Check Disk Space In Linux In Two Easy Methods (8)

As you can see, the command lists the current directory’s contents and the occupied space. You can add the -s flag to the command to further simplify the output:

# du -hs

How To Check Disk Space In Linux In Two Easy Methods (9)

You can add the path of a directory to the command to show the details of that directory. For instance, you can use the following command to get the details of the /etc command:

# du -hs /etc

How To Check Disk Space In Linux In Two Easy Methods (10)

You might see a permission denied error for some directories. This indicates that the current user lacks the rights to access the directory. We recommend using the sudo command to sidestep any permission-related issues.

Use the following claims to specify the directory or file:

du -hs /etc/kernel-img.conf

Display Disk Size in 1000s Rather Than 1024s

Manufacturers of hard drives market their products in kilobyte-based sizes, where 1000 bytes = 1 kilobyte. This scale is used for all disk sizes.

On the other hand, the operating systems use a mathematical system where 1024 bytes = 1 kilobyte. As a result, a 1000 GB hard disk only provides about 930 GB of useful capacity.

You can use the du command with the -H flag to show disk space consumption in units of 1000s instead of 1024s units:

# du -H

How To Check Disk Space In Linux In Two Easy Methods (11)

Conclusion

Finding the available disk space is an essential step before installing or upgrading a software package on your server. We discussed two ways of finding out available disk space. The good thing about these methods is that you can use several flags to modify the output complexity and details.

If you’re looking for a robust server for your Ubuntu projects, RedSwitches offers the best-dedicated server pricing and delivers instant dedicated servers, usually on the same day the order gets approved. Whether you need a dedicated server, a traffic-friendly 10Gbps dedicated server, or a powerful bare metal server, we are your trusted hosting partner.

FAQs

Q. How can I monitor disk usage in Linux?

Linux provides several tools for monitoring disk usage, including df (disk free) and du (disk usage) commands. These utilities display information about disk space usage at the filesystem level and directory level, respectively.

Q. How can I free up disk usage in Linux?

To liberate disk space in Linux, begin by pinpointing the files or directories consuming the most storage. The du command can help you evaluate the space usage of particular directories. Once you have identified the directories or files that use a lot of disk space, you can delete, move, or compress them to free up disk space.

Q. What’s a simple method to view available disk space in Linux?

Utilize the df command accompanied by the -h flag in Linux to see the free disk space.

Q. Can I check the disk space on a remote Linux server?

You can check the disk space on a remote Linux server using the df command. Simply SSH into the remote server and run the df command as you would on a local machine.

Q. Can you explain inodes and their connection to storage space?

Inodes in Unix-style file systems serve as data structures holding details about files and folders, encompassing attributes like permissions, ownership, and file size. Every file or directory utilizes one inode. The aggregate count of inodes in a file system dictates its potential capacity, indicating the maximum number of files it can accommodate.

Q. What’s the method to determine storage devices utilization for a particular directory in Linux?

In Linux, you can examine the storage consumption of a distinct directory by using the du command and the directory’s path. As an illustration, to view the storage devices used by the /home directory, execute du /home.

Q. Is it possible to determine the storage utilization of an individual file in Linux?

Absolutely; in Linux, you can gauge the storage devices usage of a particular file with the du command, accompanied by the file’s path. Nonetheless, the du command’s primary function is to assess directories’ storage consumption

Q. How do the df and du commands in Linux differ when examining disk space?

The df command showcases the disk space utilized and remaining on entire file systems while du zeroes in on the space occupied by individual files or directories. Essentially, df offers a bird’s-eye view of storage at the file system level, whereas du lets you delve into the specifics of directories or files.

Q. How do I use a Disk Usage Analyzer in Linux?

Most Linux distributions come with built-in Disk Usage Analyzers, such as du (disk usage) command-line utility or graphical tools like Baobab (Disk Usage Analyzer) for GNOME desktop environment and KDirStat for KDE. To use these tools, simply launch them from the application menu or run the command in the terminal and specify the directory you want to analyze.

How To Check Disk Space In Linux In Two Easy Methods (2024)
Top Articles
Gulp – Don’t drink the pool water!
Crypto Wallet Addresses: What They Are and How to Create One [2023] | BitPay
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Selly Medaline
Latest Posts
Article information

Author: Jamar Nader

Last Updated:

Views: 6270

Rating: 4.4 / 5 (75 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Jamar Nader

Birthday: 1995-02-28

Address: Apt. 536 6162 Reichel Greens, Port Zackaryside, CT 22682-9804

Phone: +9958384818317

Job: IT Representative

Hobby: Scrapbooking, Hiking, Hunting, Kite flying, Blacksmithing, Video gaming, Foraging

Introduction: My name is Jamar Nader, I am a fine, shiny, colorful, bright, nice, perfect, curious person who loves writing and wants to share my knowledge and understanding with you.