A Guide About Using Magento 2 CLI

by Syed Maad Jahangir  January 4, 2016

With the new version of Magento 2, there is a newer CLI tool available as well which is more powerful than the previous Mage tool. I’ll be sharing how you can use the CLI with the most common options that we will be using while managing your store.

Magento 2 CLI


As the name suggest, this option can manipulate the Magento’s Caching option. You can enable, disable, clean, flush or check status of magento’s caching with this option. Few examples are:


The indexer will be a more widely used option in Magento 2 as now there is no method to update indexing manually from Magento’s Admin. Besides reindexing, you have the options to set indexing mode and to check the status of indexer via CLI.


With this option, you can create admin user from command line or you can unlock the users that are already created.


This option can be used to enable, disable, uninstall or check status of all the installed modules of Magento. Disabling or uninstalling of module will fail with this option if there is any dependency of that module. Few examples are:


With this option, we can execute the scheduled Magento’s Cron jobs manually. You can put this command in the scheduler, so the application’s task can be executed in a timely manner.


There are plenty of things you can do with this option, but we’ll go through two of them as I think these are ones which you will be using more frequently.

a- Backup

We can backup our application’s code, database, and media files through this option. Backup can be found in var/backup/directory of your web root.

b- Config:set

This option can be used to make configuration changes on Magento. The changes involve DB parameters, admin URL, etc. You can see your provided values reflected in app/etc/env.php file.

Fairly speaking, we have more freedom in working via command line on this new version of Magento. With this flexibility, there is little need for using Magento admin for store management.

We know that we do not have Magento 2 as an app on Cloudways. Well, we are creating a dedicated stack for Magento 2 websites. Till then, you can install Magento 2 on PHP using this tutorial. We recommend you to use our plain PHP stack.

Start Creating Web Apps on Managed Cloud Servers Now!

Easy Web App Deployment for Agencies, Developers and E-Commerce Industry

About Syed Maad Jahangir

Syed Maad Jahangir worked as Senior System Engineer at Cloudways.

Stay Connected:

You Might Also Like...

  • Nice overview of CLI commands. It will be great you can also add a not for Cache cleanup/flush in case merchant is using Varnish/Memcache/Redis etc as a backend server. Also, for Magento Developers information about how to create your custom CLI command will be useful. Thanks