SSH Command in Linux with examples

Disk and storage commands in Linux

Check free space, find what is using it, and work with disks and mounts.

#df

Free disk space

Syntaxdf [options]
  • df -h

    Space per disk in human-readable sizes

  • df -hT /

    One filesystem including its type

  • df -i

    Inode usage (a disk can be "full" of tiny files)

#du

Space used by folders

Syntaxdu [options] path
  • sudo du -sh /var/log

    Total size of a folder

  • sudo du -h --max-depth=1 /var 2>/dev/null

    Size of each sub-folder (2>/dev/null hides the errors for folders you cannot open)

  • du -ah . | sort -rh | head -20

    The twenty biggest items under here

#lsblk

List disks and partitions

Syntaxlsblk
  • lsblk

    Tree of disks and where they are mounted

  • lsblk -f

    Add file system type and labels

#blkid

Show disk IDs

Syntaxsudo blkid
  • sudo blkid

    UUID and type of every partition

#mount

Attach a disk

Syntaxsudo mount device folder
  • mount

    List what is mounted

  • sudo mount /dev/sdb1 /mnt/data

    Mount a partition

  • sudo mount -o ro /dev/sdb1 /mnt/data

    Mount it read-only

#umount

Detach a disk

Syntaxsudo umount folder
  • sudo umount /mnt/data

    Safely unmount

#fdisk

Partition a disk

Syntaxsudo fdisk [-l] device
  • sudo fdisk -l

    List all disks and partitions

CarefulPartitioning and formatting destroy data. Double-check the device name (for example /dev/sdb) before you press Enter.

#mkfs

Format a partition

Syntaxsudo mkfs.type device
  • sudo mkfs.ext4 /dev/sdb1

    Create an ext4 file system (erases the partition)

#fsck

Check a file system

Syntaxsudo fsck device
  • sudo fsck /dev/sdb1

    Check and repair (the disk must be unmounted)

#free

Memory use

Syntaxfree [-h]
  • free -h

    RAM and swap in human-readable sizes

Run these commands with SSH Command

SSH Command is a desktop app for Mac, Windows and Linux that puts a real terminal, SFTP file panes, a sudo switch and a searchable Linux command finder in one window. Type what you want to do, and send the command to your server with one click.

Download free Windows commands with examples SFTP & FTP client