Is there an android shell or adb command that I could use to get a device's IMEI/MEID?

Viewed 81634

Is there some adb or android shell command that I could run that would return a device's IMEI or MEID number? Preferably that's all that would be returned.

8 Answers

The following ADB command works for me to get the IMEI:

adb shell "service call iphonesubinfo 1 | cut -c 52-66 | tr -d '.[:space:]'"

For the IMEI, maybe this command is easier to understand

db -s <device id> shell  service call iphonesubinfo 1 | cut -c 52-66 | tr -d '.[:space:]'
  • db -s <device id> shell service call iphonesubinfo 1 gets the full result, for example
Result: Parcel(
      0x00000000: 00000000 0000000f 00350033 00340037 '........3.5.7.4.'
      0x00000010: 00350032 00370030 00310032 00390039 '2.5.0.7.2.1.9.9.'
      0x00000020: 00370034 00000032                   '4.7.2...        ')
  • cut -c 52-66 trims away all columns except 52-66, using the above example
........3.5.7.4
2.5.0.7.2.1.9.9
4.7.2...       
  • and tr -d '.[:space:]' trims off any '.' and white space, using the example above
357425072199472

Warning A downside of this approach is that it is brittle, in the sense that the output must always be in the same format, having the exact same columns. I verified it on CentOs and OS X, but an update to the adb version could break this command simply by adjusting the whitespace in the output.

Related