Tell me more ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

What command can I use to retrieve the system's serial number from the unix command line? As uname will output some information about the software and hardware, I would like to retrieve the serial number from a command to use in a script.

share|improve this question

1 Answer

up vote 12 down vote accepted

The system_profiler command is perhaps the best tool for the job (assuming you are on 10.3 or newer), but you can also use ioreg for the task.

system_profiler SPHardwareDataType is the data type that contains the core hardware information, and you can use grep or awk to pare things down further as needed:

  • system_profiler SPHardwareDataType | awk '/Serial/ {print $4}'
  • ioreg -l | awk '/IOPlatformSerialNumber/ { print $4;}'
share|improve this answer
1  
+1 - Great answer bmike. – boehj Feb 18 '12 at 23:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.