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.
MacOS Terminal – Finding Mac Serial Number Programmatically
command linehardwaremacosserial numberterminal
Related Question
- Mac – Stolen Mac – Help Finding Serial Number
- MacBook – way to find out information on battery through macbook serial number
- Can Apple collect the used Mac’s serial number and other hardware information if I use the Apple ID on it
- How to find the serial number of the Apple Keyboard USB on a mac programmatically from the terminal
- How to Access MacBook’s Serial Number
- How to perform a serial number search
- macOS – How to Query Hardware UUID Programmatically from Command Line
Best Answer
The system_profiler command provides a direct answer that’s easily human readable (assuming you are on 10.3 or newer), but you can also use ioreg for the task as it generally completes faster.
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:or
Both of those commands take between 0.5 and 0.2 seconds to run on modern SSD Macs, so if you want to optimize the command and remove the " you can have your answer in 0.005s or so: