I would highly recommend running Linux in a VM. All the software is available freely to download and there is no practical difference between running in a VM and running natively for the purposes of learning the command line.
Furthermore, Linux command line mostly consists of bash + GNU coreutils, which is very different from BSD Unix (and OS X is a succedessor of BSD Unix). There is a very big difference of preferences in writing arguments in BSD Unix and GNU Linux. You can bite yourself even as non-newbie with different options to standard utilities like
tar if you work on both systems.
Using OS X when your book is Linux specific will regularly throw up inconsistencies and differences that will appear superficial when you're more experienced, but will simply be confusing when you're learning. Keep things easy for yourself.
This will also allow you to experiment without the worry of breaking your machine by deleting or changing any important files.
And last, though certainly not least, it will allow you to set up a SSH connection to your VM from your OS X Terminal, so you can get used to using SSH keys, and to the idea that it makes no difference whether your Linux server is a native machine, a local VM, or running out on AWS or Digital Ocean: it all works the same!