You can do this via `adb`. Does not require root, as far as I know (tested on a Galaxy Nexus running 4.2.1 built from AOSP source):

    shell@android:/ $ content query --uri content://settings/secure --projection value --where "name='android_id'"              
      Row: 0 value=<your ID in hexadecimal>