First you´ll need the cli utility called mas, using homebrew:
$ brew install mas
When it´s ready, use the following command to download El Capitan
$ mas install 1147835434
Mas will download the installer from the App Store, using the ID specified.