Other Applications
Which are the most commonly used Magento CLI commands?

Which are the most commonly used Magento CLI commands?

In this article, we would provide information on the most used Magento CLI commands and how to execute them. The first thing you need to do is to connect to your account via SSH. Then switch to your Magento application’s document root. If it is located in the primary domain of your account, you should go to the public_html/ folder of your account using the command below:

cd www/domain.com/public_html

The Magento CLI binary should be executed with PHP cli. If you are in the public_html/ of your account, you should use the following command to run it:

/usr/local/php72/bin/php-cli bin/magento

After the path to the Magento binary (bin/magento), you should add the exact command you want to execute. For example – the command you should use to flush the application’s cache is cache:flush. What you should execute in the Magento document root is as follows:

/usr/local/php72/bin/php-cli bin/magento cache:flush

List commands

list – lists all available commands


/usr/local/php72/bin/php-cli bin/magento list


To get more information on how a command should be executed and what are its available options, use –help after the command. For example to review the available options for the list command, execute the following:

/usr/local/php72/bin/php-cli bin/magento list --help

You may add –help after any command to get more information about it.


There are 4 main commands that can help you manage the maintenance of your Magento store.

  • maintenance:status – this is the command you may use to check the maintenance status of your store
  • maintenance:disable – executing this one would deactivate maintenance mode
  • maintenance:enable – this one is used to activate maintenance mode
  • maintenance:allow-ips – this command is used to deactivate maintenance mode for a certain IP address. It requires additional parameter – your IP address. You should add it after the command as shown below:
/usr/local/php72/bin/php-cli bin/magento maintenance:allow-ips

where should be the IP address you want to allow. If you want to add multiple IPs, separate them with a space.

To clear all allowed IP addresses, use –none as a parameter:

/usr/local/php72/bin/php-cli bin/magento maintenance:allow-ips --none


There are 3 commands used to manage sample data:

  • sampledata:deploy – you should use this command to deploy sample data modules
  • sampledata:remove – this one’s purpose is to remove all sample data packages from composer.json
  • sampledata:reset – execute this command to reset all sample data modules and re-install them

Admin actions

In case you forgot your admin user’s username or password, you may easily create a new one by using the admin:user:create command. This one requires at least five additional parameters – username, password, email address, first and last name.


/usr/local/php72/bin/php-cli bin/magento admin:user:create --admin-user=USERNAME --admin-password=PASSWORD --admin-firstname=NAME --admin-lastname=SURNAME --admin-email=EMAIL

where you should substitute USERNAME, PASSWORD, NAME, SURNAME and EMAIL with the necessary values.

Cache management

To flush your Magento application’s cache, you should use the cache:flush command. Additionally, if you want to clear only certain types of cache, just add the type as a parameter after the command. For example, if you want to flush the full_page and config_webservice caches only, execute the command below:

/usr/local/php72/bin/php-cli bin/magento cache:flush full_page config_webservice

To disable or enable caching for certain types, use the commands below:

  • cache:disable
/usr/local/php72/bin/php-cli bin/magento cache:disable full_page config_webservice
  • cache:enable
/usr/local/php72/bin/php-cli bin/magento cache:enable full_page config_webservice

Resize images

catalog:images:resize – this command is used to resize catalog images

/usr/local/php72/bin/php-cli bin/magento catalog:images:resize


To manually run the cron jobs for your application, execute the command below:

/usr/local/php72/bin/php-cli bin/magento cron:run


  • indexer:info – using this one you may check the available indexes and their system name
  • indexer:status – you can use this command to check the status of the indexes
  • indexer:reindex – if executed without additional parameters, reindexes all indexes. If you want to run it for certain indexes, you should add their system names as parameters as shown below:
/usr/local/php72/bin/php-cli bin/magento indexer:reindex customer_grid design_config_grid


  • module:disable – disables the modules specified as parameters
  • module:enable – enables specified modules
  • module:status – displays status of modules
  • module:uninstall – uninstalls modules installed by composer

Usage (for the purpose of this article we would disable, enable and uninstall a module named SY_Callback):

/usr/local/php72/bin/php-cli bin/magento module:disable SY_Callback
/usr/local/php72/bin/php-cli bin/magento module:enable SY_Callback
/usr/local/php72/bin/php-cli bin/magento module:uninstall SY_Callback

You may add multiple modules separated with space.


  • setup:backup – takes a backup of Magento Application code base, media or database, and stores the backup in var/backups/. You should specify as additional parameters what the backup should contain. If you want to back up the code base, media, and database, use the command below:
/usr/local/php72/bin/php-cli bin/magento setup:backup --code --media --db
  • setup:db-data:upgrade – installs and upgrades data in the DB
  • setup:db-schema:upgrade – installs and upgrades the DB schema
  • setup:di:compile – generates DI configuration and all missing classes that can be auto-generated. You should run it during deployment of changes such as theme change.
  • setup:static-content:deploy – deploys static view files
  • setup:upgrade – upgrades the Magento application, DB data, and schema

Share This Article