Magento 2 Command Line Interface: useful commands

Merchants that use Magento 2 know it has a console command line. However, not all of the newbies know how to use it all out. Here we have decided to share the knowledge and give some useful tips.

How to work with Magento 2 Command Line Interface?

To use the CLI you will have to complete three simple steps.

Step 1: check Php_cli

  • Php_cli is installed to your Magento 2 by default with PHP, so you can simply check it typing the php-v command into your command line.
  • In case you don’t see php_cli, navigate to your Magento 2 root folder and type in: php bin/magento. If you see the list of commands, the php_cli has been installed correctly. Don’t forget to switch to the magento 2 file system owner.

Step 2: most in-demand Magento 2 CLI commands

Common CLI commands

Command Meaning
php bin/magento magento setup:cache:{enable|disable|clean|flush|status} manage the cache;
php bin/magento setup:indexer:{status|show-mode|set-mode|reindex|info} manage the indexers;
php bin/magento cron:run use cron jobs;
php bin/magento setup:di:compile compile all non-existent proxies/factories; pre-compile class definitions, inheritance information, and plug-in definitions for one store and website;
php bin/magento info:dependencies:{show-modules|show-modules-circular|show-framework} module dependencies, circular dependencies, Magento framework dependencies;
php bin/magento i18n:{collect-phrases|pack} generate a translation dictionary or a translation package;
php bin/magento setup:static-content:deploy deploy static view files;
php bin/magento dev:source-theme:deploy generate CSS from LESS
php bin/magento dev:tests:run run automated tests;
php bin/magento dev:xml:convert update your layout XML files to match the new Extensible Stylesheet Language Transformations (XSLT) stylesheet;
php bin/magento setup:perf:generate-fixtures generate data to use for performance testing;
php bin/magento sampledata:install install optional Magento sample data after you install the Magento application.


Haven’t you found a necessary command? Enter magento --list to display a complete list of commands:


See here to find any additional information.

Common arguments:

The arguments displayed on the screenshot are common for all commands. 


Step 3: use a necessary command

The commands can be added in one of the next ways:

  • php magento <command>
  • /magento <command>
  • magento <command> ¡only after adding <your Magento install dir>/bin to your system PATH!
Rate the answer?