Magento 2 CLI Commands with syntax and description

Magento 2 CLI Command format:

Syntax:

[code]
> php <your Magento install dir>/bin/magento <command name>
[/code]

Magento 2 CLI Command for module status. To see the status of module enable or disable:

[code]
> php bin/magento module:status
[/code]

Magento 2 CLI Command to enable the module:

[code]
php bin/magento module:enable { Extension-Name }
i.e. php bin/magento module:enable Coddu_HelloWorld
[/code]

Magento 2 CLI Command for clear cache:

[code]
php bin/magento cache:clean
[/code]

Magento 2 CLI Command for clear cache flush:

[code]
> php bin/magento cache:flush
[/code]

Magento 2 CLI Command for upgrade or Magento 2 CLI Command for upgrade module/extension:

[code]
> php bin/magento setup:upgrade
[/code]

Magento 2 CLI Command for reindex url (Magento 2 indexing):

[code]
> php bin/magento index:reindex
[/code]

Magento 2 CLI Command for compile or Magento 2 command for generate classes:

[code]
> php bin/magento setup:di:compile
[/code]

Magento 2 CLI Command for static content deploy:

Syntax:

[code]
bin/magento setup:static-content:deploy [<languages>] [-t|–theme[="<theme>
"]] [–exclude-theme[="<theme>"]] [-l|–language[="<language>"]] [–exclude-language[="<language>"]] [-a|–area[="
<area>"]] [–exclude-area[="
<area>"]] [-j|–jobs[="<number>"]] [–no-javascript] [–no-css] [–no-less] [–no-images] [–no-fonts] [–no-html] [–no-misc] [–no-html-minify] [-d|–dry-run]
[/code]

Example:

[code]
> php bin/magento setup:static-content:deploy -f
[/code]

Magento 2 CLI Command to set up the mode:

There are three types of a mode in Magento 2.
1. Production
2. Develop
3. Default

To switch from one Magento 2 mode to another, it is easy to update via CLI Command.

Magento 2 CLI Command to show active/enabled mode:

[code]
> php bin/magento deploy:mode:show
[/code]

Magento 2 CLI Command for set the mode:

[code]
> php bin/magento deploy:mode:set {mode} [-s|–skip-compilation]
[/code]

Magento 2 CLI Command for developer mode:

[code]
> php bin/magento deploy:mode:set developer
[/code]

Magento 2 CLI Command for production mode:

[code]
> php bin/magento deploy:mode:set production
[/code]

Magento 2 CLI Command for default mode:

[code]
> php bin/magento deploy:mode:set default
[/code]