Get a Macs Serial Number from the Command Line
You can quickly retrieve any Macs serial number via the command line by using the following command string:
system_profiler |grep "r (system)"
The command results will look something like this:
$ system_profiler |grep "r (system)"
Serial Number (system): C24E1322XXXX
If you just grep for “Serial Number” you’ll be presented with serial numbers to other hardware included in the Mac, which is why the “r (system)” qualifier is included.
Once you have a serial number, you can do things like check AppleCare warranty status and repair history.