Magento 2 Useful Commands List
If you are like most of the developers, you will have juggled through different websites to find SSH / CLI commands for Magento 2. There is no single resource on web which has all useful commands list for Magento 2. I have been there and I know it is a sheer waste of time juggling through different sites. So, to save your time, I have compiled a list of most useful commands for Magento 2 in a single note for all the developers.
Below is the list of most important SSH / CLI commands for Magento 2 that I have found useful. To use these commands you will need to have SSH access to your server or use the Command Line for local access.
Also refer a very useful technical note for using the shortcuts of Magento2 SSH commands: Magento 2 Commands Shortcut
Setup Upgrade Using Command Line
php bin/magento setup:upgrade
If you don’t want to remove pub/static files while installing/updating database then use following command.
php bin/magento setup:upgrade --keep-generated
Cache Clean Using Command Line
php bin/magento cache:clean
Cache Flush Using Command Line
php bin/magento cache:flush
View cache status Using Command Line
php bin/magento cache:status
Enable Cache Using Command Line
php bin/magento cache:enable [cache_type]
Disable Cache Using Command Line
php bin/magento cache:disable [cache_type]
Static Content Deploy Using Command Line (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 Command Line
php 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)
php 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)
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 Command Line (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 Command Line
php bin/magento indexer:reindex
View the 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
See all modules Status Using Command Line
php bin/magento module:status
Enable module Using Command Line
php bin/magento module:enable Namespace_Module
Disable module Using Command Line
php bin/magento module:disable Namespace_Module
Uninstall Module Using Command Line
php bin/magento module:uninstall Namespace_Module
Check Current Mode Using Command Line
php bin/magento deploy:mode:show
Change To Developer Mode Using Command Line
php bin/magento deploy:mode:set developer
Change To Production Mode Using Command Line
php bin/magento deploy:mode:set production
Run the single-tenant Compiler Using Command Line
php bin/magento setup:di:compile
Unlock Admin User Using Command Line
php bin/magento admin:user:unlock adminusername
Enable Maintenance Mode Using Command Line
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 Command Line
php bin/magento maintenance:disable
Check Maintenance Mode Status Using Command Line
php bin/magento maintenance:status
Allow IP on Maintenance Mode Using Command Line
php bin/magento maintenance:allow-ips --ip=192.0.0.1 --ip=192.0.0.2
Set Magento crontab Using Command Line
php 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.
crontab -l
Remove Magento crontab Using Command Line
php bin/magento cron:remove
I hope this Magento technical note helped you find what you were looking for. This is a comprehensive list of all useful Magento 2 commands; bookmark it for your future reference. Feel free to contact us or 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.
About Emipro
Being an emerging leader in IT market since 2011, Emipro Technologies Pvt. Ltd. has been providing a wide range of business solutions in Odoo & Magento. We are pleased to have a large pool of contented customers with our meticulous work in the domain of ERP & e-Commerce. Our customers are companies of all sizes ranging from startups to large enterprises who realize that they need a professional internet solution to generate revenue streams, establish proper communication channels, to achieve desired goals and streamline business operations. [....] Read More
Our writings seems informative ?
Subscribe for our Magento Technical Notes and get more amazing stuff directly to your inbox!
Post Your Review

Yasar Nowsath
Posted on 19 January, 2019Thank you very much for this essential list, this is great!!
Dhanush
Posted on 13 December, 2018Thanks a lot for these Commands..Really helpful.!!!.
Vikram
Posted on 17 November, 2018Lovely :) Great Thanx!!
aj
Posted on 21 October, 2018Tnxxxxxxxxxxxx bosss
sudheeran
Posted on 12 October, 2018Thank you
yasar nowsath
Posted on 3 October, 2018php bin/magento dev:template-hints:enable php bin/magento dev:template-hints:disable please add this two commands in ur lists...
husain
Posted on 3 August, 2018Thanks for providing very usefully command M2 GREAT THANKS
webetutorial
Posted on 17 July, 2018Nice post, this is very helpful post.
krishna
Posted on 27 June, 2018really Helpful
Rajasekar
Posted on 25 June, 2018Thanks..
Julias
Posted on 22 March, 2018It is good work.... It is really helpful. Thanks
Ismail
Posted on 23 December, 2017Thanks Bro. now its on my bookmark bar, very useful.
Fahim
Posted on 6 November, 2017Thank you so much! its really usefull.
BlackBike
Posted on 21 August, 2017Thank you very much for this essential list, this is great!!
Zakir
Posted on 2 August, 2017Thanks.
Mage Lover
Posted on 1 August, 2017Hello Mayank, Thanks for sharing this great tutorial about Magento 2 useful commands.
Mage Lover
Posted on 1 August, 2017Hello Mayank, Thanks for sharing this great tutorial about Magento 2 useful commands.
Parth M
Posted on 28 June, 2017Every time I have to look into countless forums and articles for a single command, but this was such a most useful post I have seen with a list of most useful commands for Magento 2. You are the genius man!
Mitesh
Posted on 19 June, 2017This technical note is very useful and all type of commands are covered in this note.Thank You...