How to fix the «Command line user does not have read and write permissions on var/generation directory» issue?

Command line user does not have read and write permissions on var/generation directory.
Please address this issue before using Magento command line.

You can fix it with the command:

chmod -R -v 777 var/generation

See also: