list linux partition names only in bash

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


df will display only mounted partitions. If that's what you want then to extract the device nodes from df output you grep for the lines starting with "/dev" and cut the first column out of the remaining output:

df | grep '^/dev' | cut -d' ' -f1 

or to list them on a single line separated by spaces:

df | grep '^/dev' | cut -d' ' -f1 | tr '\n' ' '

If you want to get a list of partitions which are not necessarily mounted then as root you can run fdisk -l and optionally specify device(s) to scan for partitions:

fdisk -l [device...]

If you don't specify any device then fdisk will use devices mentioned in /proc/partitions if that file exists.

Fdisk will output information in a similar format as df so to extract device nodes you can do the same thing as described for df:

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