The following operations are available for Mac and Linux.
Download mirror
Download the mirror, the default is the latest desktop version, other versions can visit Download Raspbian for Raspberry Pi
curl -o raspbian-stretch.zip https://downloads.raspberrypi.org/raspbian_latest
decompress
unzip raspbian-stretch.zip
Please note that the decompressed file name will be similar
2017-11-29-raspbian-stretch.img
depending on the version. Please note that it will be changed in the following brushing action.
View memory card
df -h
Unmount the memory card
sudo diskutil unmount /dev/diskXs1
Flash the image to the memory card
sudo dd bs=1m if=./2017-11-29-raspbian-stretch.img of=/dev/rdiskX
Eject the memory card
sudo diskutil eject /dev/rdiskX
test
Plug it into the Raspberry Pi and try it out.