Various storage devices.

Linux disk information and monitoring tools

Linux offers a several tools to monitor, analyze, and manage disk usage and structure. These tools help solving storage bottlenecks, understanding directory hierarchies, and managing space efficiently.

Linux disk information and monitoring

Linux offers a variety of command-line tools to monitor, analyze, and manage disk usage and structure. These tools help in identifying storage bottlenecks, understanding directory hierarchies, and managing disk space efficiently.

Commonly Used Tools

df

Displays disk space usage for file systems.

Syntax: df [options]
Example:

df -h             # Outputs disk usage in a readable format.

Key Options:

  • -h: Human-readable format (e.g., KB, MB, GB).
  • -T: Display file system type.

du

Syntax: du [options] [path]
Key Options:
    -h: Human-readable format.
    -s: Summary of total size.
    --max-depth=N: Limits output depth.
Example:

du -h --max-depth=1 /home

Displays sizes of directories under /home.

Analyzes disk space used by directories or files.

ncdu

Interactive disk usage viewer (alternative to du).

Usage:
    Navigate with arrow keys.
    Delete files directly (requires confirmation).
Example:

ncdu /home

Launches an interactive view of /home.

lsblk

Lists information about block devices (e.g., disks, partitions).

Syntax: lsblk [options]
Key Options:
    -f: Displays file system information.
    -o NAME,SIZE,TYPE,MOUNTPOINT: Customize output.
Example:

lsblk -f

Shows all block devices and their file systems.

blkid

Displays UUIDs and file system types of block devices.

Example:

blkid

Lists all available partitions with UUID and file system type.

tree

Displays directories as a tree structure.

Syntax: tree [options] [directory]
Key Options:
    -d: Show only directories.
    -L N: Limit depth of directory traversal.
Example:

tree -L 2 /home

Displays /home structure up to 2 levels.

findmnt

Shows currently mounted file systems in a tree format.

Syntax: findmnt [options]
Example:

findmnt

Outputs mounted file systems with details.

Specialized Tools

parted

Disk partitioning tool with detailed disk information capabilities.

Example:

parted -l

Lists all disks and partition details.

iostat

Provides CPU and I/O statistics.

Example:

iostat

Shows device-level disk I/O statistics.

lsof

Lists open files, including disk usage.

Example:

lsof +D /path

Displays open files in a specific directory.

General Usage Examples Find the largest directories:

Example:

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

Shows the top 10 largest files/directories.

Monitor real-time disk I/O:

iotop

Check disk usage per user:

du -sh /home/*

Tree structure with file sizes:

tree -sh /path

Leave a Reply

Your email address will not be published. Required fields are marked *