Useful Commands list for Magento 2
In this article, I have compiled most of the useful Magento 2 commands which we are regularly used while development. Check the following list of Magento 2 most important SSH / CLI commands that I have found useful.
Setup Upgrade Using Command Line
saveCopyzoom_out_mapphp bin/magento setup:upgrade
If you don’t want to remove pub/static files while installing/updating database then use following command.
saveCopyzoom_out_mapphp bin/magento setup:upgrade --keep-generated
Cache Clean Using Command Line
saveCopyzoom_out_mapphp bin/magento cache:clean
Cache Flush Using Command Line
saveCopyzoom_out_mapphp bin/magento cache:flush
View cache status Using Command Line
saveCopyzoom_out_mapphp bin/magento cache:status
Enable Cache Using Command Line
saveCopyzoom_out_mapphp bin/magento cache:enable [cache_type]
Disable Cache Using Command Line
saveCopyzoom_out_mapphp bin/magento cache:disable [cache_type]
Static Content Deploy Using Command Line (Use -f for force deploy on 2.2.x or later)
saveCopyzoom_out_mapphp bin/magento setup:static-content:deploy
Static Content Deploy For Particular Language Using Command Line
saveCopyzoom_out_mapphp bin/magento setup:static-content:deploy en_US
Static Content Deploy For Magento Backend Theme Using Command Line (Working on 2.1.1 or later)
saveCopyzoom_out_mapphp bin/magento setup:static-content:deploy --theme="Magento/backend"
Static Content Deploy For Specific Themes Using Command Line (Working on 2.1.1 or later)
saveCopyzoom_out_mapphp bin/magento setup:static-content:deploy --theme Magento/luma --theme Magento/second_theme
**Exclude Themes on Static Content Deploy and does not minify HTML files Using Command Line **(Working on 2.1.1 or later)
saveCopyzoom_out_mapphp bin/magento setup:static-content:deploy en_US --exclude-theme Magento/luma --no-html-minify
Reindexing Using Command Line
saveCopyzoom_out_mapphp bin/magento indexer:reindex
View the list of indexers Using Command Line
saveCopyzoom_out_mapphp bin/magento indexer:info
View indexer status Using Command Line
saveCopyzoom_out_mapphp bin/magento indexer:status
Show the mode of all indexers Using Command Line
saveCopyzoom_out_mapphp bin/magento indexer:show-mode
See all modules Status Using Command Line
saveCopyzoom_out_mapphp bin/magento module:status
Enable module Using Command Line
saveCopyzoom_out_mapphp bin/magento module:enable Namespace_Module
Disable module Using Command Line
saveCopyzoom_out_mapphp bin/magento module:disable Namespace_Module
Uninstall Module Using Command Line
saveCopyzoom_out_mapphp bin/magento module:uninstall Namespace_Module
Check Current Mode Using Command Line
saveCopyzoom_out_mapphp bin/magento deploy:mode:show
Change To Developer Mode Using Command Line
saveCopyzoom_out_mapphp bin/magento deploy:mode:set developer
Change To Production Mode Using Command Line
saveCopyzoom_out_mapphp bin/magento deploy:mode:set production
Run the single-tenant Compiler Using Command Line
saveCopyzoom_out_mapphp bin/magento setup:di:compile
Unlock Admin User Using Command Line
saveCopyzoom_out_mapphp bin/magento admin:user:unlock adminusername
Enable Maintenance Mode Using Command Line
saveCopyzoom_out_mapphp bin/magento maintenance:enable
To enable maintenance mode for all clients except 192.0.0.1 and 192.0.0.2:
saveCopyzoom_out_mapphp bin/magento maintenance:enable --ip=192.0.0.1 --ip=192.0.0.2
To clear the list of IPs.
saveCopyzoom_out_mapphp bin/magento maintenance:enable --ip=none
Disable Maintenance Mode Using Command Line
saveCopyzoom_out_mapphp bin/magento maintenance:disable
Check Maintenance Mode Status Using Command Line
saveCopyzoom_out_mapphp bin/magento maintenance:status
Allow IP on Maintenance Mode Using Command Line
saveCopyzoom_out_mapphp bin/magento maintenance:allow-ips --ip=192.0.0.1 --ip=192.0.0.2
Set Magento crontab Using Command Line
saveCopyzoom_out_mapphp bin/magento cron:install --force
Use --force to rewrite an existing Magento crontab. To view the crontab, enter the following command as the Magento file system owner.
saveCopyzoom_out_mapcrontab -l
Remove Magento crontab Using Command Line
saveCopyzoom_out_mapphp bin/magento cron:remove
I hope this article helps you find what you were looking for. Check out our other article if you are looking for Magento 2 Commands Shortcut.
Bookmark it for your future reference. Do comment below if you have any other handy commands which are not included in the list.
P.S. Do share this note with your team.
Review other articles maybe it'll help you too.