How to render in command line?
Firstly open your Command Processor.


  Windows(Command Prompt)
  Linux(Terminal)
  Mac(Command Line).




For Windows:

In cmd first type set path="C:\Program Files\Blender 2.80" replace it with path were your blender is extracted or installed. And press Enter.
Now we to locate the folder where you save your Blender files.
So in cmd, type 

cd yourpath


If you didn't get what to type after cd than make a folder named Blender Projects on your Desktop and move the .blend files in it, and in cmd type 

cd desktop\blender projects


and press Enter.
You are in the expected location,
Now,
If you want to animate,
run
this command,

blender -b yourfilename.blend -a


Rendering Single Frames

blender -b file.blend -f 10


-f 10 describes which frame you wish to render, in this case single 10th frame will be rendered.

You can also set start frame and end frame for animation just add this block in your animation command

-s 10 -e 500


-s refers to start and -e refers to end, replace numbers with yours.
You can also refer the documentation provided by Blender Foundation.


  Editing is greatly appreciated to this answer for Linux and Mac users.


Hope this information may be helpful. All the best.