Linux – list linux partition names only in bash

bashdflinux

df on linux lists the following stats on partitions.

-bash-4.1# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda3            1918217320 1473337340 347440136  81% /
tmpfs                 32970328         0  32970328   0% /dev/shm
/dev/sda1               482214    148534    308781  33% /boot
/dev/sdd1            1922860884 1638599284 186585876  90% /disk5
/dev/sdc1            1922858352 1474925416 350257336  81% /disk2
/dev/sdb1            1922858352 1028783752 796399000  57% /disk4

If I want to get a list of the partition names, for example:
"/dev/sda3 /dev/sda1 /dev/sdc1…"
how do I do it in bash?

Best Answer

To list all partitions defined for a device as root run:

lsblk

OR

fdisk -l

OR

cat /proc/partitions

And also as mentioned by @Giedrius Rekasius

fdisk -l /dev/sda | grep '^/dev' | cut -d' ' -f1

Related Topic