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=Varma
-
Unlock Admin Account
admin:user:unlock
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
catalog:images:resize
php bin/magento catalog:images:resize
-
Remove unused product attributes.
catalog:product:attributes:cleanup
php bin/magento catalog:product:attributes:cleanup
-
-
Indexing Related Commands
-
List allowed Indexers
indexer:info
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
info:adminuri
php bin/magento info:adminuri
-
Available backup files
info:backups:list
php bin/magento info:backups:list
-
Get list of available currencies
info:currency:list
php bin/magento info:currency:list
-
language locales
info:language:list
php bin/magento info:language:list
-
List of available timezones
info:timezone:list
php bin/magento info:timezone:list
-
-
Maintenance Related Commands
-
Check Maintenance Status
maintenance:status
php 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.11
-
Disable Maintenance Mode
maintenance:disable
php 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.20
-
-
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
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.