This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

A Guide About Using Magento 2 CLI

Published on January 4, 2016 - Content Updated on June 17, 2021

2 Min Read

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 Magento 2 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:

magento cache:status

magento cache:disable config

magento cache:disable full_page

magento cache:flush


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.

magento indexer:info

magento indexer:set‐mode schedule customer_grid

magento indexer:reindex customer_grid

magento indexer:reindex


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

magento admin:user:create ‐‐admin‐user="example" ‐‐admin‐password="example123" ‐‐admin‐email="[email protected]" ‐‐admin‐firstname="example" ‐‐admin‐lastname="example"


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:

magento module:status

magento module:disable example

magento module:uninstall example


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.

magento cron:run


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.

magento setup:backup ‐‐code ‐‐media ‐‐db

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.

magento setup:config:set ‐‐backend‐frontname="admin" ‐‐db‐host="localhost" ‐‐db‐name="example" ‐‐db‐user="example" ‐‐db‐password="example"

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.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Customer Review at

“Great speed, features, knowledgebase, dashboard, UX and fast, expert support. Very happy!”

Stefan [Management Consultant]

Syed Maad Jahangir

Syed Maad Jahangir worked as Senior System Engineer at Cloudways.


Get Our Newsletter
Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!


Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!