Disks and filesystems cheat sheet
The most useful disks and filesystems commands on one printable page, every line checked by running it.
dd Copy bytes between files or devices in fixed-size blocks, with optional offsets and conversions.
dd if=/dev/zero of=zeros.img bs=1M count=5 ls -l zeros.img- Create a file of a given size output
dd if=photos/beach.png bs=1 count=8 status=none | xxd- Read the first bytes of a file output
printf 'version=1.0\n' > app.ini printf '2' | dd of=app.ini bs=1 seek=8 conv=notrunc status=none cat app.ini- Overwrite bytes in place output
sudo dd if=debian.iso of=/dev/sdX bs=4M status=progress oflag=sync- Write an image to a USB stick output
df Report how much space is used and free on mounted filesystems.
du Show how much disk space files and directories use, totalled per directory.
findmnt Show mounted filesystems as a tree, or look up which filesystem a path is on and how it is mounted.
findmnt -T . -o TARGET,SOURCE,FSTYPE- Which filesystem is this directory on output
findmnt -t devpts,mqueue- All mounts of certain types output
if findmnt -rn /mnt/backup > /dev/null; then echo "backup disk mounted" else echo "backup disk NOT mounted, skipping" fi- Test whether something is mounted output
findmnt --verify --tab-file fstab- Check an fstab for mistakes output
lsblk List block devices (disks, partitions, LVM volumes, loop devices) as a tree, with sizes and mount points.
mount Attach a filesystem (a disk partition, image, network share or tmpfs) to a directory, or list what is mounted.
mount --fstab fstab -a --fake -v- Dry-run an fstab with --fake output
sudo mkdir -p /mnt/data sudo mount /dev/sdb1 /mnt/data- Mount a disk partition output
sudo mount -o ro,noexec,nosuid /dev/sdb1 /mnt/data- Mount read-only and without executables output
sudo mount -o loop,ro debian.iso /mnt/iso- Mount a disk image or ISO file output
truncate Shrink or extend a file to an exact size, creating it if needed.
From https://opscape.vip/cheatsheets/disk/ · checked 2026-10-31