Linux Disk Management and File System Related Commands


Here are some commands to assist with mastering disks and file systems on Linux.

Disk Usage

See total usage

The du command is quite powerful but be aware of it’s performance implications if you’re running it against large subdirectories.

First change to a specific directory, then do this:

du -h --max-depth=1
du --summarize

See usage sorted by size

Use the following command to sort disk usage by size in the current directory:

sudo du -ks $(ls -d */) | sort -nr | cut -f2 | xargs -d '\n' du -sh 2> /dev/null

Note: This command can take very long on a large server. On a 800 GB server with an SSD array it took around 10 minutes before output was produced.

Determine the Linux file system type

df -Th | grep "^/dev"

Find out which Linux partitions exist on a file system

fdisk -l

From the manual:
-l     List  the  partition  tables  for  the specified devices and then exit.  If no devices are given, those mentioned in /proc/partitions (if that exists) are used.

Share this article

Leave a Reply

Your email address will not be published.

Scroll to Top