Skip to main content

Checking Disk Space with df and du

Checking Disk Space with df and du Checking Disk Space with df and du

Checking Disk Space with df and du

Understanding the df Command

The df command is used to display the amount of disk space available on the filesystem. It provides an overview of the space utilization on all mounted filesystems.

Syntax:

df [options] [filesystems]

Common Options:

  • -h: Human-readable format, displaying sizes in KB, MB, GB, etc.
  • -T: Displays the type of filesystem.
  • -i: Displays inode usage.

Examples:

Basic Usage:

df

This command outputs the disk space usage of all mounted filesystems.

Human-Readable Format:

df -h

The -h option provides a more readable output, using units like KB, MB, and GB.

Including Filesystem Type:

df -T

The -T option displays the type of each filesystem.

Understanding the du Command

The du command is used to estimate file and directory space usage. Unlike df, which shows overall filesystem usage, du provides details on specific directories and files.

Syntax:

du [options] [directories]

Common Options:

  • -h: Human-readable format.
  • -a: Displays usage for all files, not just directories.
  • -s: Provides a summary of the total disk usage for the specified directories.
  • -c: Adds a grand total at the end of the output.

Examples:

Basic Usage:

du

This command outputs the disk usage of the current directory and its subdirectories.

Human-Readable Format:

du -h

The -h option provides a more readable output.

Summarizing Disk Usage:

du -sh

The -s and -h options together provide a summarized and human-readable output of the current directory's usage.

Including All Files:

du -ah

The -a option includes all files in the output.

Practical Use Cases

Combining df and du:

Checking Overall Usage and Identifying Large Directories:

df -h

Review the overall disk usage, then identify large directories:

du -sh /*

This command lists the disk usage of all directories at the root level, helping you pinpoint which ones consume the most space.

Finding Large Files:

du -ah / | sort -n -r | head -n 10

This command lists the top 10 largest files and directories in the root directory.

Conclusion

Effective disk space management is crucial for maintaining optimal system performance. The df and du commands are powerful tools that provide comprehensive insights into disk usage. By combining these commands and utilizing their options, you can monitor and manage your disk space efficiently, ensuring your system runs smoothly.

© 2025 Linux Playground

Comments

Popular posts from this blog

Configuring Network Interfaces

Configuring Network Interfaces Configuring Network Interfaces Configuring network interfaces is a critical task for both system administrators and enthusiasts looking to optimize the performance and security of their networked devices. Network interfaces are the gateways that connect a device to a network, whether it's a local area network (LAN), wide area network (WAN), or the internet. This article will delve into the essential steps and considerations for configuring network interfaces across various operating systems and environments. Understanding Network Interfaces A network interface can be either physical, like an Ethernet port, or virtual, like those used in virtual machines or containers. Each network interface has a unique Media Access Control (MAC) address and can be assigned an IP address. Proper configuration ensures efficient data transmission, network security, and optimal performance. Steps to Config...

ACLs: Access Control Lists

ACLs: Access Control Lists ACLs: Access Control Lists Introduction Access Control Lists (ACLs) are a fundamental aspect of network security and management, crucial for ensuring that only authorized users have access to specific resources within a network. As networks become more complex, ACLs serve as a vital tool for administrators to control the flow of traffic and enforce security policies. What Are ACLs? An Access Control List is a set of rules that dictate what kind of traffic is allowed to enter or exit a network. These rules are applied to network devices such as routers and switches to control the movement of data packets. Each rule within an ACL specifies whether to permit or deny traffic based on criteria such as source and destination IP addresses, protocol types, and port numbers. Types of ACLs Standard ACLs These ACLs filter traffic based only on the source IP address. They are simpler bu...

Understanding IP Addressing and Subnetting

Understanding IP Addressing and Subnetting Understanding IP Addressing and Subnetting by Linux Playground What is an IP Address? An Internet Protocol (IP) address is a unique numerical identifier assigned to each device connected to a network that uses the Internet Protocol for communication. Think of it as the digital equivalent of a home address, guiding data packets to their destination. Types of IP Addresses IPv4 (Internet Protocol version 4): Consists of 32 bits, divided into four octets. Commonly represented as dotted-decimal notation (e.g., 192.168.1.1). Supports approximately 4.3 billion unique addresses. IPv6 (Internet Protocol version 6): Introduced to address IPv4 exhaustion. Consists of 128 bits, divided into eight groups of hexadecimal digits (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334). Suppo...