Magento 2 Essential Useful Commands List
If you think that you are like most of
the other developers, and you try to find list of Magento2 commands for SSH/CLI
through different websites. You may not find a single resource on web which has
all essentially useful command list for Magento2. I am also one of you before I
listed all command from different resource and I also knew that it is a waste
of time to juggling through different sites for finding it. That’s why I
compiled a list of most essential useful commands for Magento 2 in a single
note for save time of you my friend and all other developers.
Here in bellow is the most important
SSH/CLI commands list for Magento 2, which I have found useful. For the use of
these commands you must have SSH access to your server or you may use the
command line for local access.
Magento 2 Essential Useful Commands List
Setup Upgrade Using CLI
php bin/magento setup:upgrade
If you don’t want to delete pub/static files while
installing/updating database then use this command.
php bin/magento setup:upgrade --keep-generated
Cache Clean Using CLI
php bin/magento cache:clean
Cache Flush Using CLI
php bin/magento cache:flush
View cache status Using CLI
php bin/magento cache:status
Enable Cache Using CLI
php bin/magento cache:enable [cache_type]
Disable Cache Using CLI
php bin/magento cache:disable [cache_type]
Static Content Deploy Using CLI (Use -f for force deploy on
2.2.x or later)
php bin/magento setup:static-content:deploy
Static Content Deploy For Particular
Language Using CLI
php bin/magento setup:static-content:deploy en_US
Static Content Deploy For Magento
Backend Theme Using CLI
(Working on 2.1.1 or later)
php bin/magento setup:static-content:deploy
--theme="Magento/backend"
Static Content Deploy For Specific
Themes Using CLI (Working
on 2.1.1 or later)
php 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 CLI (Working on 2.1.1 or later)
php bin/magento setup:static-content:deploy en_US --exclude-theme
Magento/luma --no-html-minify
Reindexing Using CLI
php bin/magento indexer:reindex
View the list of indexers Using CLI
php bin/magento indexer:info
View indexer status Using CLI
php bin/magento indexer:status
Show the mode of all indexers Using CLI
php bin/magento indexer:show-mode
See all modules Status Using CLI
php bin/magento module:status
Enable module Using CLI
php bin/magento module:enable Namespace_Module
Disable module Using CLI
php bin/magento module:disable Namespace_Module
Uninstall Module Using CLI
php bin/magento module:uninstall Namespace_Module
Check Current Mode Using CLI
php bin/magento deploy:mode:show
Change To Developer Mode Using CLI
php bin/magento deploy:mode:set developer
Change To Production Mode Using CLI
php bin/magento deploy:mode:set production
Run the single-tenant Compiler Using
CLI
php bin/magento setup:di:compile
Unlock Admin User Using CLI
php bin/magento admin:user:unlock adminusername
Enable Maintenance Mode Using CLI
php bin/magento maintenance:enable
To enable maintenance mode for all clients except
192.0.0.1 and 192.0.0.2:
php bin/magento maintenance:enable --ip=192.0.0.1 --ip=192.0.0.2
To clear the list of IPs.
php bin/magento maintenance:enable --ip=none
Disable Maintenance Mode Using CLI
php bin/magento maintenance:disable
Check Maintenance Mode Status Using CLI
php bin/magento maintenance:status
Allow IP on Maintenance Mode Using CLI
php bin/magento maintenance:allow-ips --ip=192.0.0.1 --ip=192.0.0.2
Set Magento crontab Using CLI
php bin/magento cron:install --force
Use --force to rewrite
an existing Magento crontab.
To view the crontab, enter the bellow command as the Magento file system owner.
crontab -l
Remove Magento crontab Using CLI
php bin/magento cron:remove