As we all know, Magento 2 is highly dependent on the CLI(Command Line Interface) for tasks like content deploy, reindexing, etc. There is no specific resource from where we can get a list of all the commands. So while developing with Magento 2 we require to run various commands many times. It is very time-consuming and complicated to find the required commands from different websites again and again.
Today in this blog post I will give you a list of all the commands which are useful for Magento 2 development.
Here the list of most important SSH / CLI commands for Magento 2. To use these commands you will need to have SSH access to your server or you can use the Command Line for local access.
Setup upgrade using Command Line
php bin/magento setup:upgrade
Setup upgrade without remove pub/static files using Command Line
php bin/magento setup:upgrade --keep-generated
Flush cache using Command Line
php bin/magento cache:flush
Flush cache with specific type using Command Line
php bin/magento cache:flush cache_type
Check cache status using Command Line
php bin/magento cache:status
Cache clean using Command Line
php bin/magento cache:clean
Cache clean with specific type using Command Line
php bin/magento cache:clean cache_type
Disable cache using Command Line
php bin/magento cache:disable
Disable cache with specific type using Command Line
php bin/magento cache:disable cache_type
Enable cache using Command Line
php bin/magento cache:enable
Enable cache with specific type using Command Line
php bin/magento cache:enable cache_type
Static content deploy using using Command Line (Use -f for force deploy on 2.2.x or later)
php bin/magento setup:static-content:deploy or php bin/magento setup:static-content:deploy -f
Static content deploy for specific language using Command Line
php bin/magento setup:static-content:deploy -f en_AU
Static content deploy for Magento backend theme using Command Line
php bin/magento setup:static-content:deploy -f --theme="Magento/backend"
Static content deploy for specific fronend theme using Command Line
php bin/magento setup:static-content:deploy -f --theme Magento/luma
Exclude themes on static content deploy using Command Line
php bin/magento setup:static-content:deploy -f en_US --exclude-theme Magento/luma
Does not minify HTML files on static content deploy using Command Line
php bin/magento setup:static-content:deploy -f --no-html-minify
Reindexing using Command Line
php bin/magento indexer:reindex
List of indexers using Command Line
php bin/magento indexer:info
View indexer status using Command Line
php bin/magento indexer:status
Show the mode of all indexers using Command Line
php bin/magento indexer:show-mode
Reset indexer status to invalid using Command Line
php bin/magento indexer:reset
Set index mode type
php bin/magento indexer:set-mode {schedule|realtime} [indexer]
For example:
php bin/magento indexer:set-mode schedule catalog_category_product catalog_product_category
Check current mode using Command Line
php bin/magento deploy:mode:show
Set developer mode using Command Line
php bin/magento deploy:mode:set developer
Set production mode using Command Line
php bin/magento deploy:mode:set production
See all modules status using Command Line
php bin/magento module:status
Enable module using Command Line
php bin/magento module:enable VendorName_ModuleName
Disable module using Command Line
php bin/magento module:disable VendorName_ModuleName
Uninstall module using Command Line
php bin/magento module:uninstall VendorName_ModuleName
Check maintenance mode status using Command Line
php bin/magento module:enable VendorName_ModuleName
Enable maintenance mode using Command Line
php bin/magento module:disable VendorName_ModuleName
Enable maintenance mode for all clients except specific IPs
php bin/magento maintenance:enable --ip=127.0.0.1 --ip=127.0.0.2
Allow IP on maintenance mode using Command Line
php bin/magento maintenance:allow-ips --ip=127.0.0.1 --ip=127.0.0.2
Clear the list of IPs using Command Line
php bin/magento maintenance:enable --ip=none
Disable maintenance mode using Command Line
php bin/magento maintenance:disable