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
      admin:user:create
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento admin:user:create --admin-user=rakesh --admin-password=Admin@123 --admin-email=info@example.com --admin-firstname=Rakesh --admin-lastname=Varma
      php bin/magento admin:user:create --admin-user=rakesh --admin-password=Admin@123 --admin-email=info@example.com --admin-firstname=Rakesh --admin-lastname=Varma
      php bin/magento admin:user:create --admin-user=rakesh --admin-password=Admin@123 --admin-email=info@example.com --admin-firstname=Rakesh --admin-lastname=Varma
    • Unlock Admin Account
      admin:user:unlock
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento admin:user:unlock rakesh
      php bin/magento admin:user:unlock rakesh
      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]
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      # 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
      # 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
      # 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]
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      # Disable only Configuration and Fullpage Cache
      php bin/magento cache:disable config full_page
      # Disable All Caches
      php bin/magento cache:disable
      # Disable only Configuration and Fullpage Cache php bin/magento cache:disable config full_page # Disable All Caches php bin/magento cache:disable
      # 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]
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      # Enable only Configuration and Fullpage Cache
      php bin/magento cache:enable config full_page
      # Enable All Caches
      php bin/magento cache:enable
      # Enable only Configuration and Fullpage Cache php bin/magento cache:enable config full_page # Enable All Caches php bin/magento cache:enable
      # 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]
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      # Flush only Configuration and Fullpage Cache
      php bin/magento cache:flush config full_page
      # Flush All Caches
      php bin/magento cache:flush
      # Flush only Configuration and Fullpage Cache php bin/magento cache:flush config full_page # Flush All Caches php bin/magento cache:flush
      # 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
      catalog:images:resize
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento catalog:images:resize
      php bin/magento catalog:images:resize
      php bin/magento catalog:images:resize
    • Remove unused product attributes.
      catalog:product:attributes:cleanup
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento catalog:product:attributes:cleanup
      php bin/magento catalog:product:attributes:cleanup
      php bin/magento catalog:product:attributes:cleanup
  • Indexing Related Commands

    • List allowed Indexers
      indexer:info
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento indexer:info
      php bin/magento indexer:info
      php bin/magento indexer:info
    • Reindexes Data.
      indexer:reindex [indexer1] [indexer2] [indexer..n]
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento indexer:reindex
      php bin/magento indexer:reindex
      php bin/magento indexer:reindex
    • Resets indexer status to invalid.
      indexer:reset [indexer1] [indexer2] [indexer..n]
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento indexer:reset inventory
      php bin/magento indexer:reset inventory
      php bin/magento indexer:reset inventory
    • Set index mode type.
      indexer:set-mode {schedule|realtime} [indexer]
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento indexer:set-mode schedule catalog_category_product
      php bin/magento indexer:set-mode schedule catalog_category_product
      php bin/magento indexer:set-mode schedule catalog_category_product
    • Check Index Mode
      indexer:show-mode [indexer]
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento indexer:show-mode catalog_category_product
      php bin/magento indexer:show-mode catalog_category_product
      php bin/magento indexer:show-mode catalog_category_product
    • Check status of Indexer
      indexer:status [indexer]
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento indexer:status catalog_category_product
      php bin/magento indexer:status catalog_category_product
      php bin/magento indexer:status catalog_category_product
  • Website related commands

    • Magento Admin URIt
      info:adminuri
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento info:adminuri
      php bin/magento info:adminuri
      php bin/magento info:adminuri
    • Available backup files
      info:backups:list
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento info:backups:list
      php bin/magento info:backups:list
      php bin/magento info:backups:list
    • Get list of available currencies
      info:currency:list
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento info:currency:list
      php bin/magento info:currency:list
      php bin/magento info:currency:list
    • language locales
      info:language:list
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento info:language:list
      php bin/magento info:language:list
      php bin/magento info:language:list
    • List of available timezones
      info:timezone:list
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento info:timezone:list
      php bin/magento info:timezone:list
      php bin/magento info:timezone:list
  • Maintenance Related Commands

    • Check Maintenance Status
      maintenance:status
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento maintenance:status
      php bin/magento maintenance:status
      php bin/magento maintenance:status
    • Enable Maintenance Mode
      maintenance:enable [--ip= ... --ip=]
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento maintenance:enable --ip=192.0.2.10 --ip=192.0.2.11
      php bin/magento maintenance:enable --ip=192.0.2.10 --ip=192.0.2.11
      php bin/magento maintenance:enable --ip=192.0.2.10 --ip=192.0.2.11
    • Disable Maintenance Mode
      maintenance:disable
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento maintenance:disable
      php bin/magento maintenance:disable
      php bin/magento maintenance:disable
    • Exclude IPs for maintenance mode
      maintenance:allow-ips ..
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento maintenance:allow-ips 192.168.1.15 192.168.1.20
      php bin/magento maintenance:allow-ips 192.168.1.15 192.168.1.20
      php bin/magento maintenance:allow-ips 192.168.1.15 192.168.1.20
  • Module Related Commands

    • Disable Modules
      module:disable [-c|--clear-static-content] [-f|--force] [--all]
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento module:disable Magento_Weee
      php bin/magento module:disable Magento_Weee
      php bin/magento module:disable Magento_Weee
    • Enable Module
      module:enable [-c|--clear-static-content] [-f|--force] [--all]
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      php bin/magento module:disable Magento_Weee
      php bin/magento module:disable Magento_Weee
      php bin/magento module:disable Magento_Weee
    • Get Status of modules
      module:status [module-list]
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      # Disaply status of Module Magento_Weee
      php bin/magento module:status Magento_Weee
      # Disaply status of All Modules
      php bin/magento module:status
      # Disaply status of Module Magento_Weee php bin/magento module:status Magento_Weee # Disaply status of All Modules php bin/magento module:status
      # 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]
      Plain text
      Copy to clipboard
      Open code in new window
      EnlighterJS 3 Syntax Highlighter
      bin/magento module:uninstall Magento_Contact
      bin/magento module:uninstall Magento_Contact
      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