Skip to content

Instantly share code, notes, and snippets.

@rvill
Created January 16, 2015 04:05
Show Gist options
  • Save rvill/60ce9d7016581b84c343 to your computer and use it in GitHub Desktop.
Save rvill/60ce9d7016581b84c343 to your computer and use it in GitHub Desktop.
get iOS device UDID without xcode or itunes, using linux cmd line
lsusb -v 2> /dev/null | grep -e "Apple Inc" -A 2
@yahyaarslan
Copy link

Thanks :)

@zyphlar
Copy link

zyphlar commented Jul 12, 2022

This version works:
lsusb -slsusb | grep "Apple" | cut -d ' ' -f 2:lsusb | grep "Apple" | cut -d ' ' -f 4 | sed 's/://' -v | grep iSerial | awk '{print $3}'
however you need to add a hyphen after the 8th character like 00001111-01010101010101

@menvol3
Copy link

menvol3 commented Nov 18, 2022

Maybe there is a command for Android devices to fetch UDID without Android-SDK?

@Tosi-kun
Copy link

You can also obtain the UDID in the following way:

  1. Connect your device to the computer via USB.
  2. Run the command idevice_id -l to obtain the ID of the connected device.
  3. Run the command ideviceinfo -u [device ID obtained in step 2].
  4. Look for the "UniqueDeviceID:" field, where you can find the UDID.

One line command: ideviceinfo -u $(idevice_id -l) | awk '/UniqueDeviceID:/ {print $2}'

@GoodMirek
Copy link

This version works: lsusb -slsusb | grep "Apple" | cut -d ' ' -f 2:lsusb | grep "Apple" | cut -d ' ' -f 4 | sed 's/://' -v | grep iSerial | awk '{print $3}' however you need to add a hyphen after the 8th character like 00001111-01010101010101

The command with fixed formatting:

lsusb -s `lsusb | grep "Apple" | cut -d ' ' -f 2`:`lsusb | grep "Apple" | cut -d ' ' -f 4 | sed 's/://'` -v | grep iSerial | awk '{print $3}'

Instead of backticks, it is possible to use $() notion, which does not confuse markup that much:

lsusb -s $(lsusb | grep "Apple" | cut -d ' ' -f 2):$(lsusb | grep "Apple" | cut -d ' ' -f 4 | sed 's/://') -v | grep iSerial | awk '{print $3}'

@diegorondini
Copy link

lsusb -d 05ac: -v 2>/dev/null | grep iSerial | awk '{print $NF}'

@meramsey
Copy link

A variation on @GoodMirek response that adds the hypen for you in the right spot(after the 8th character)

lsusb -s $(lsusb | grep "Apple" | cut -d ' ' -f 2):$(lsusb | grep "Apple" | cut -d ' ' -f 4 | sed 's/://') -v | grep iSerial | awk '{print $3}' | sed 's/^\(........\)/\1-/'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment