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
php bin/magento admin:user:create --admin-user=rakesh --admin-password=Admin@123 --admin-email=info@example.com --admin-firstname=Rakesh --admin-lastname=Varmaphp bin/magento admin:user:create --admin-user=rakesh --admin-password=Admin@123 --admin-email=info@example.com --admin-firstname=Rakesh --admin-lastname=Varmaphp 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
php bin/magento admin:user:unlock rakeshphp bin/magento admin:user:unlock rakeshphp 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 Cachephp bin/magento cache:clean config full_page# Clean All Enable Cachephp 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]
# Disable only Configuration and Fullpage Cachephp bin/magento cache:disable config full_page# Disable All Cachesphp 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]
# Enable only Configuration and Fullpage Cachephp bin/magento cache:enable config full_page# Enable All Cachesphp 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]
# Flush only Configuration and Fullpage Cachephp bin/magento cache:flush config full_page# Flush All Cachesphp 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
php bin/magento catalog:images:resizephp bin/magento catalog:images:resizephp bin/magento catalog:images:resize
-
Remove unused product attributes.
catalog:product:attributes:cleanup
php bin/magento catalog:product:attributes:cleanupphp bin/magento catalog:product:attributes:cleanupphp bin/magento catalog:product:attributes:cleanup
-
-
Indexing Related Commands
-
List allowed Indexers
indexer:info
php bin/magento indexer:infophp bin/magento indexer:infophp bin/magento indexer:info
-
Reindexes Data.
indexer:reindex [indexer1] [indexer2] [indexer..n]
php bin/magento indexer:reindexphp bin/magento indexer:reindexphp bin/magento indexer:reindex
-
Resets indexer status to invalid.
indexer:reset [indexer1] [indexer2] [indexer..n]
php bin/magento indexer:reset inventoryphp bin/magento indexer:reset inventoryphp bin/magento indexer:reset inventory
-
Set index mode type.
indexer:set-mode {schedule|realtime} [indexer]
php bin/magento indexer:set-mode schedule catalog_category_productphp bin/magento indexer:set-mode schedule catalog_category_productphp bin/magento indexer:set-mode schedule catalog_category_product
-
Check Index Mode
indexer:show-mode [indexer]
php bin/magento indexer:show-mode catalog_category_productphp bin/magento indexer:show-mode catalog_category_productphp bin/magento indexer:show-mode catalog_category_product
-
Check status of Indexer
indexer:status [indexer]
php bin/magento indexer:status catalog_category_productphp bin/magento indexer:status catalog_category_productphp bin/magento indexer:status catalog_category_product
-
-
Website related commands
-
Magento Admin URIt
info:adminuri
php bin/magento info:adminuriphp bin/magento info:adminuriphp bin/magento info:adminuri
-
Available backup files
info:backups:list
php bin/magento info:backups:listphp bin/magento info:backups:listphp bin/magento info:backups:list
-
Get list of available currencies
info:currency:list
php bin/magento info:currency:listphp bin/magento info:currency:listphp bin/magento info:currency:list
-
language locales
info:language:list
php bin/magento info:language:listphp bin/magento info:language:listphp bin/magento info:language:list
-
List of available timezones
info:timezone:list
php bin/magento info:timezone:listphp bin/magento info:timezone:listphp bin/magento info:timezone:list
-
-
Maintenance Related Commands
-
Check Maintenance Status
maintenance:status
php bin/magento maintenance:statusphp bin/magento maintenance:statusphp bin/magento maintenance:status
-
Enable Maintenance Mode
maintenance:enable [--ip= ... --ip=]
php bin/magento maintenance:enable --ip=192.0.2.10 --ip=192.0.2.11php bin/magento maintenance:enable --ip=192.0.2.10 --ip=192.0.2.11php bin/magento maintenance:enable --ip=192.0.2.10 --ip=192.0.2.11
-
Disable Maintenance Mode
maintenance:disable
php bin/magento maintenance:disablephp bin/magento maintenance:disablephp bin/magento maintenance:disable
-
Exclude IPs for maintenance mode
maintenance:allow-ips ..
php bin/magento maintenance:allow-ips 192.168.1.15 192.168.1.20php bin/magento maintenance:allow-ips 192.168.1.15 192.168.1.20php 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]
php bin/magento module:disable Magento_Weeephp bin/magento module:disable Magento_Weeephp bin/magento module:disable Magento_Weee
-
Enable Module
module:enable [-c|--clear-static-content] [-f|--force] [--all]
php bin/magento module:disable Magento_Weeephp bin/magento module:disable Magento_Weeephp bin/magento module:disable Magento_Weee
-
Get Status of modules
module:status [module-list]
# Disaply status of Module Magento_Weeephp bin/magento module:status Magento_Weee# Disaply status of All Modulesphp 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]
bin/magento module:uninstall Magento_Contactbin/magento module:uninstall Magento_Contactbin/magento module:uninstall Magento_Contact
-
For More Useful Command you can follow these links
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.