magento 2 CLI command

Magento 2 Useful CLI Command List

As a Magento 2 developer on a daily basis We have to perform some basic operations like deploy content, Install a new Module, etc. For these kinds of tasks, Magento Provides a bunch of Useful Magento 2 CLI command which are helpful for us.

In this article, I have listed some Magento 2 CLI command for caches, indexer,module etc. which needs more often while we are in developing stage.

  • Admin Related Commands

    • Create new administrator account
      php bin/magento admin:user:create --admin-user=rakesh --admin-password=Admin@123 --admin-firstname=Rakesh --admin-lastname=Varma
    • Unlock Admin Account
      php bin/magento admin:user:unlock rakesh
  • Cache Related Commands

    • Clean cache type(s)
      php bin/magento cache:clean [cache_tag1] [cache_tag2] [cache_tag..n]
      # Clean only Configuration and Fullpage Cache
      php bin/magento cache:clean config full_page
      # Clean All Enable Cache 
      php bin/magento cache:clean config full_page
    • Disable cache type(s)
      cache:disable [cache_tag1] [cache_tag2] [cache_tag..n]
      # Disable only Configuration and Fullpage Cache
      php bin/magento cache:disable config full_page
      # Disable All Caches
      php bin/magento cache:disable
    • Enable cache type(s)
      cache:enable [cache_tag1] [cache_tag2] [cache_tag..n]
      # Enable only Configuration and Fullpage Cache
      php bin/magento cache:enable config full_page
      # Enable All Caches
      php bin/magento cache:enable
    • Flush cache storage used by cache type(s)
      cache:flush [cache_tag1] [cache_tag2] [cache_tag..n]
      # Flush only Configuration and Fullpage Cache
      php bin/magento cache:flush config full_page
      # Flush All Caches
      php bin/magento cache:flush
  • Product Related Commands

    • Create resized product images
      php bin/magento catalog:images:resize
    • Remove unused product attributes.
      php bin/magento catalog:product:attributes:cleanup
  • Indexing Related Commands

    • List allowed Indexers
      php bin/magento indexer:info
    • Reindexes Data.
      indexer:reindex [indexer1] [indexer2] [indexer..n]
      php bin/magento indexer:reindex
    • Resets indexer status to invalid.
      indexer:reset [indexer1] [indexer2] [indexer..n]
      php bin/magento indexer:reset inventory
    • Set index mode type.
      indexer:set-mode {schedule|realtime} [indexer]
      php bin/magento indexer:set-mode schedule catalog_category_product
    • Check Index Mode
      indexer:show-mode [indexer]
      php bin/magento indexer:show-mode catalog_category_product
    • Check status of Indexer
      indexer:status [indexer]
      php bin/magento indexer:status catalog_category_product
  • Website related commands

    • Magento Admin URIt
      php bin/magento info:adminuri
    • Available backup files
      php bin/magento info:backups:list
    • Get list of available currencies
      php bin/magento info:currency:list
    • language locales
      php bin/magento info:language:list
    • List of available timezones
      php bin/magento info:timezone:list
  • Maintenance Related Commands

    • Check Maintenance Status
      php bin/magento maintenance:status
    • Enable Maintenance Mode
      maintenance:enable [--ip= ... --ip=]
      php bin/magento maintenance:enable --ip= --ip=
    • Disable Maintenance Mode
      php bin/magento maintenance:disable
    • Exclude IPs for maintenance mode
      maintenance:allow-ips ..
      php bin/magento maintenance:allow-ips
  • Module Related Commands

    • Disable Modules
      module:disable [-c|--clear-static-content] [-f|--force] [--all]
      php bin/magento module:disable Magento_Weee
    • Enable Module
      module:enable [-c|--clear-static-content] [-f|--force] [--all]
      php bin/magento module:disable Magento_Weee
    • Get Status of modules
      module:status [module-list]
      # Disaply status of Module Magento_Weee
      php bin/magento module:status Magento_Weee
      # Disaply status of All Modules
      php bin/magento module:status
    • Uninstalls modules installed by composer
      module:uninstall [module-list]
      bin/magento module:uninstall Magento_Contact

For More Useful Command you can follow these links

Magento Open Source

Magento Commerce

Hope you find this Tutorial is helpful. Do comment if you face any issue or Contact me If you want any help or customization in your existing Project or Extension.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top