To use Magento 2 Command line Interface, you need to follow:

  • Step 1: Install Php_cli
  • Step 2:  Some most common  command line in Magento 2
  • Step 3: Use command line that you want

Step 1: Install Php_cli

To use the Magento 2 console, you must install the php_cli. Please go to the Magento 2 root folder and type:


php bin/magento

magento 2 command

magento 2 command


If the list of command is show, the php_cli is installed so you can use the Magento 2 console normally. If it is not show, you should install the php_cli.

If your sever is ubuntu, you can install by the command:

Sudo apt-get install php-cli

Step 2: Some most used command line in Magento 2 Command Line Interface (CLI):

  • Install module and upgrade module: php bin/magento setup:upgrade
  • Switch to the developer mode or production mode: php bin/magento deploy:mode:set developer (or production)
  • Show current mode: php bin/magento deploy:mode:show
  • Deploy static content: php bin/magento setup:static-content:deploy
  • Di compile: php bin/magento setup:di:compile
  • Reindex: php bin/magento indexer:reindex
  • Flush magento cache: php bin/magento cache:flush

Step 3: Use command line that you want

You can also use php bin/magento to show all the command line.

Thank you!