settings get secure android_id
from a shell/terminaladb shell
is the simplest, I find — no extraneous output and does not require root. (From a regular terminal on the device, root is required.)
shell@mydevice:/ $ settings get secure android_id
0123456789abcdef
shell@mydevice:/ $