Disk usage and management
Guide to Disk Commands: df, du, free, mount, umount

Growing in DevOps, together! 🤝 | Associate Software Engineer at Tech Mahindra | Enthusiastic about automation, cloud solutions, and efficient software delivery. | Let's connect, collaborate, and learn from each other!
1. df (Disk Filesystem Usage)
The df command displays the amount of disk space used and available on mounted filesystems.
Common Options:
-h → Human-readable format
-T → Shows file system type (e.g., ext4, xfs)
-i → Displays inode usage instead of disk space
To show the disk usage in human-readable format (MB/GB).
df -hTo force the output to show sizes in KB/GB/MB.
BM (mega bytes), BG(giga), BK (Kilobytes)
df -h -BKTo display file system
df -T

2. du (Disk Usage)
It shows the size of files and directories.
Common Options:
-s → Shows total size of a directory
-h → Human-readable format
-c → Displays a total at the end of the output.
-a → Shows the size of all files (not just directories).
To displays total size of
/home/user/in a human-readable format.du -sh <directory-name>

For more granular info - files
du -ah <filename>
To display a grand total
du -ahc
3. free
It is used to check system memory usage in Linux, including RAM and swap space.
Displays memory usage in bytes by default.
free -h
To continuously monitor memory usage at regular intervals.
free -s NThe
-s <seconds>option allows you to set the refresh rate.Keep refreshing memory after N sec

Exit after repeating N times

4. mount (Mount a Filesystem)
The
mountcommand attaches a storage device (e.g., USB, external drive) to a directory in the filesystem.To mount
/dev/sdb1(USB) to/mnt/usb.mount /dev/sdb1 /mnt/usbCommon Options:
mount -o ro /dev/sdb1 /mnt/usb→ Mount in read-only modemount -t ext4 /dev/sdb1 /mnt/usb→ Mount with a specific filesystem type
To list all mounted filesystems:
mount | column -t
5. unmount (Unmount a Filesystem)
The umount command detaches a mounted filesystem.
To unmount the USB drive from
/mnt/usb.umount /mnt/usb




